admin管理员组

文章数量:1426480

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.

本文标签: phpHow to reload the entire page from an ajax responseStack Overflow