简体   繁体   English

使用AJAX从服务器获取数据后如何重定向到另一个URL?URL重定向不起作用

[英]How to redirect to another URL after fetching data from the server using AJAX?URL redirect not working

Please take a look at the other post I made. 请看看我发表的另一篇文章。 Click here: How to invoke PHP file in AJAX/JavaScript? 单击此处: 如何在AJAX / JavaScript中调用PHP文件? I thought everything is working fine until the confirmation box in JavaScript. 我以为一切正常,直到JavaScript中的确认框。 I have used window.location and window.location.href but neither of them worked. 我使用过window.locationwindow.location.href,但它们都不起作用。 The confirmation dialogue appears but when the user click the OK button, it just return to the same page. 出现确认对话框,但是当用户单击“确定”按钮时,它仅返回到同一页面。 Please help. 请帮忙。

// Try this  
       redirect = response.getHeader('Location');
                document.location = redirect; 

location.replace also useful for redirecting the page. location.replace对重定向页面也很有用。 location.replace('../addmedia.php?add=movies');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM