ajax页面刷新表单提交成功

时间:2014-01-09 16:35:06

标签: javascript php jquery ajax

我正在使用此ajax代码提交表单

<script type="text/javascript">
$(document).ready(function(){
$("#ticketupdate_message").hide();
$("#ticketupdate_please_wait_box").hide();
$("#ticket_update").submit(function(e){
    $("#ticketupdate_message").hide();
    $("#ticketupdate_please_wait_box").show();
    e.preventDefault();
    dataString=$("#ticket_update").serialize();
    $.ajax({
        type: "POST",
        url: "reviewtickets_history.php?seq=<?php echo $_GET["seq"]; ?>",
        cache: false,
        data: dataString,
        success: function(res){
            $("#ticketupdate_please_wait_box").hide();
            $("#ticketupdate_message").html(res);
            $('#ticketupdate_message').fadeIn('slow');
            $('.overlay').fadeOut();
            if(res.indexOf("success")!=-1)
            {
                window.location.href = res.substr(8);
            }
            else
            {
                $("#ticket_update")[0].reset();
            }
        }
    });
});
});
</script>

如果成功,我该如何添加页面刷新?

3 个答案:

答案 0 :(得分:1)

使用location.reload();重新加载页面

if(res.indexOf("success")!=-1)
{
    location.reload();
}

参考:MDN

答案 1 :(得分:1)

您可以使用location.reload();

答案 2 :(得分:0)

使用location.reload() https://developer.mozilla.org/en-US/docs/Web/API/Location.reload

     if(res.indexOf("success")!=-1)
        {
            location.reload();
        }

如果要覆盖缓存,请添加true参数:location.reload(true);

干杯