【发布时间】:2016-01-29 21:03:46
【问题描述】:
我正在尝试在 jQuery ajax 请求的成功功能上刷新页面后显示引导模式。我认为发生的事情是,一旦页面刷新,setTimeout 就会被清除,因此它永远不会触发。我需要页面刷新内容,但也想为用户提供一个显示发生了什么的对话框。
这是我的代码:
$.ajax({
type: "POST",
url: '@Url.Action("UpdateVideoUrl", "ManageVideos")',
data: JSON.stringify(model),
contentType: 'application/json',
success: function () {
location.reload(true);
$(window).scrollTop(0);
setTimeout(function () {
$("#SuccessModal").modal('show');
}, 200);
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(textStatus + ": " + errorThrown + "." + " Please see above if applicable");
}
});
如果我将超时设置为 100,则模式开始显示并且页面刷新并且我失去了模式。有没有办法完成这个任务?
【问题讨论】:
标签: jquery ajax twitter-bootstrap bootstrap-modal