how to refresh page in php
i'm using ajax call on the php page(my.php) to pass JS variables and JS array to another php page(destiny.php). Now in destiny.php i do some DB operations.
$.ajax({
type: "POST",
url: "destiny.php",
data: { b_Array : b_arr, b_value : b_val},
success: function(data) {
window.alert(data);
}
But sometimes due to user inputted error (through Js variables or Js array), i have to show an alert (right now using above code window.alert(data)
to show alert) But it doesn't refresh the page.
how can i refresh the page then? i tried header(). but still it doesn't work.
试试window.location
$.ajax({
type: "POST",
url: "destiny.php",
data: { b_Array : b_arr, b_value : b_val},
success: function(data) {
window.location = "your_url";
});
$.ajax(
{
type: "POST",
url: "destiny.php",
data: { b_Array : b_arr,
b_value : b_val},
success: function(data) {
**window.location.reload();**
}
但我觉得清爽不是一个好主意
window.location.reload(true);
This is the best way to reach what you want, although you also may check out this code bellow:
function auto_reload()
{
var timer = window.location.reload();
for (var i=0;i<timer.length;i++){
setTimeout(timer, 1000);
timer = false;
}
}
I hope it helps!
链接地址: http://www.djcxy.com/p/28688.html上一篇: jquery popup提交应该用struts2动作调用刷新父窗口
下一篇: 如何在PHP中刷新页面