[英]ajax page refresh on form submit success
i am using this ajax code to submit a form 我正在使用此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>
how can i add a page refresh if it was successful? 如果成功,我如何添加页面刷新?
您可以使用location.reload();
Using location.reload()
https://developer.mozilla.org/en-US/docs/Web/API/Location.reload : 使用location.reload()
https://developer.mozilla.org/zh-CN/docs/Web/API/Location.reload :
if(res.indexOf("success")!=-1)
{
location.reload();
}
If you want to override cache, add a true
parameter: location.reload(true);
如果要覆盖缓存,请添加一个true
参数: location.reload(true);
Cheers 干杯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.