[英]How can I make a redirect page in jQuery/JavaScript when using ajax?
How can I redirect the user from one page to another using jQuery -> Ajax? 如何使用jQuery - > Ajax将用户从一个页面重定向到另一个页面? Thanks for your time.
谢谢你的时间。
Try this if you want to redirect to another page once ajax call is success, 如果您想在ajax调用成功后重定向到另一个页面,请尝试此操作,
$.ajax({
url: "page1.html",
success:function(result){
document.location.href="page2.html";
}});
$.ajax({
url:"http://where.to/redirect",,
async:false,
});
This will load the url synchroniously, that means redirect the user "in jquery/javascript when using ajax". 这将同步加载url,这意味着在使用ajax时“在jquery / javascript中重定向用户”。 To "make a redirect page", write this:
要“制作重定向页面”,请写下:
<script type="application/javascript" language="javascript">
$.ajax({
url:"http://where.to/redirect",,
async:false,
});
</script>
... tada! ...田田! We have a "a redirect page in jQuery/JavaScript when using ajax"!
我们在使用ajax时有一个“jQuery / JavaScript中的重定向页面”! ;)
;)
// Through an HTTP redirect //通过HTTP重定向
window.location.replace(" http://stackoverflow.com "); window.location.replace(“ http://stackoverflow.com ”);
// Through by clicking on a link //通过点击链接
window.location.href = " http://stackoverflow.com "; window.location.href =“ http://stackoverflow.com ”;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.