ajax页面刷新表单提交成功
我正在使用此ajax代码提交表单
$(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=", 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(); } } }); }); });
如果成功,我该如何添加页面刷新?
使用location.reload();
重新加载页面
if(res.indexOf("success")!=-1) { location.reload(); }
参考: MDN
你可以使用location.reload();
使用location.reload()
https://developer.mozilla.org/en-US/docs/Web/API/Location.reload :
if(res.indexOf("success")!=-1) { location.reload(); }
如果要覆盖缓存,请添加一个true
参数: location.reload(true);
干杯