jQuery Ajax PHP重定向到另一个页面 [英] jQuery Ajax PHP redirecting to another page
本文介绍了jQuery Ajax PHP重定向到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
JavaScript文件:
JavaScript file:
$.ajax({
type: "POST",
url: "ajax.php",
data: dataString,
success: function(r)
{
$("#div").html(r);
}
});
我想在成功的情况下将页面重定向到new.php
,因此在ajax.php
文件中我使用了header('Location:new.php');
,但是不是将其重定向到页面new.php
,而是将new.php
的内容加载到
I want to redirect the page to new.php
on success condition so in the ajax.php
file I used header('Location:new.php');
but instead of redirecting to page new.php
it is loading the content of new.php
in the div
.
我需要进行哪些更改才能将现有页面重定向到一个全新的页面?
What changes do I need to make in order to redirect the existing page to a whole new page?
推荐答案
$.ajax({
type: "POST",
url: "ajax.php",
data: dataString,
success: function(r)
{
window.location = 'new.php';//window.location.href = 'new.php';
//$("#div").html(r);
},
});
这篇关于jQuery Ajax PHP重定向到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文