在表单提交成功的AJAX页面刷新 [英] ajax page refresh on form submit success
本文介绍了在表单提交成功的AJAX页面刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用这阿贾克斯code提交表单
i am using this ajax code to submit a form
<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();
刷新页面
if(res.indexOf("success")!=-1)
{
location.reload();
}
请参考: MDN 一>
这篇关于在表单提交成功的AJAX页面刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文