2014-01-09 95 views
1

我用这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> 

我如何添加一个页面刷新,如果它是成功的?

+0

如果重新载入页面,什么是你在'success'回调有其他行动的地步? – Barmar

+0

其他操作不会在那里,我将删除它们,当我设法使页面刷新 – charlie

+0

刷新页面将nuke你对成功处理程序内的页面所做的任何更改... –

回答

1

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

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

参见:MDN

1

可以使用location.reload();