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!
我有一个用php生成的网页,表格放在div中。表单使用Ajax提交并在服务器端验证。如果有错误,div的内容将替换为带有错误消息的更新表单。如果表单中没有错误,我想从ajax响应中重新加载整个页面,而不仅仅是div。有谁知道这是怎么做到的吗?我已经尝试发送位置标题,但它将新页面放在div中。我也尝试过javascript window.location,但是当收到ajax响应时,我不知道是不是很热。我没有使用jQuery所以我想在计划javascript和/或php中这样做。提前致谢!
1 个解决方案
#1
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.
老实说,这种做法违背了异步做事的目的。
#1
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.
老实说,这种做法违背了异步做事的目的。