![](/img/trans.png)
[英]How to call a Jquery method on page load or page refresh in jquery
[英]JQuery AJAX - How to refresh/reload page using a method GET call
由于某种原因,我无法使此代码正常工作,我正在尝试使用GET重新加载/刷新页面。 我找到的所有示例代码都使用POST,但我不能这样做,因为我们的表单需要GET。
这是我的代码:
$.ajax({type: "GET",
url: "CorrectResults",
data: data,
beforeSend: function() {
console.log("Submitting Data");
},
cache: false,
success: function(html) {
document.location.reload();
//location.reload(true);
//$("#acceptDiv").html(html);
}
});
这应该是完成此操作的简单方法,为什么使用POST而不使用GET如此简单?
开始了:
$.ajax({type: "GET",
url: "CorrectResults",
data: data,
beforeSend: function() {
console.log("Submitting Data");
},
cache: false,
success: function(html) {
window.location.href= "../yourUrl";
}
});
希望能帮助到你;)
如果脚本中没有其他错误(请在浏览器中按F12进入控制台),则可以尝试使用location.reload();
在您的成功方法中,像这样:
$.ajax({type: "GET",
url: "CorrectResults",
data: data,
beforeSend: function() {
console.log("Submitting Data");
},
cache: false,
success: function(html) {
location.reload();
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.