最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - How to reload the entire page from an ajax response? - Stack Overflow

programmeradmin1浏览0评论

I have a web page generated with php with a form placed within a div. The form is submitted using Ajax and validated on the server side. If there is an error, the contents of the div is replaced with an updated form with error messages. If the form has no errors in it, I want to reload the entire page from the ajax response, not just the div. Does anyone know how to do that? I have tried sending location header but it places the new page in the div. I have also tried javascript window.location but I don't know hot to get it executed when the ajax response has been received. I am not using jQuery so I want to do this in plan javascript and/or php. Thanks in advance!

I have a web page generated with php with a form placed within a div. The form is submitted using Ajax and validated on the server side. If there is an error, the contents of the div is replaced with an updated form with error messages. If the form has no errors in it, I want to reload the entire page from the ajax response, not just the div. Does anyone know how to do that? I have tried sending location header but it places the new page in the div. I have also tried javascript window.location but I don't know hot to get it executed when the ajax response has been received. I am not using jQuery so I want to do this in plan javascript and/or php. Thanks in advance!

Share Improve this question asked Aug 30, 2012 at 19:41 Thomas LennartssonThomas Lennartsson 411 silver badge2 bronze badges 1
  • 3 If you use Ajax, why do you want to reload the page? – Bergi Commented Aug 30, 2012 at 19:46
Add a ment  | 

1 Answer 1

Reset to default 7

Yes, you can do that in your callback as follows:

location.reload(true);

Honestly, that kind of defeats the purpose of doing something asynchronously.

发布评论

评论列表(0)

  1. 暂无评论