function AddScheduledCandidate() {
if (ValidateScheduledCandidate()) {
InsertGoogleEvent($('#comment').val(), $('#SchDateTime').val() );
$.post(WebsiteURL + 'VideoRepository/AddScheduledCandidate', { id: $('#hdnId').val() }, "json")
.done(function (response) {
window.location.href = response.Url;
})
}
}
上面代码中的问题是我的页面在插入谷歌日历信息之前被重定向。这是因为我知道jquery代码不会逐行执行,并且在完成谷歌日历事件之前,会触发重定向代码并且不会插入谷歌日历记录。任何帮助将不胜感激。
谢谢
似乎插入谷歌事件是异步服务器调用,因此请尝试以下操作来同步调用。
function AddScheduledCandidate() {
if (ValidateScheduledCandidate()) {
$.post(WebsiteURL + 'VideoRepository/AddScheduledCandidate', { id: $('#hdnId').val() }, "json")
.done(function (response) {
InsertGoogleEvent($('#comment').val(), $('#SchDateTime').val() );
window.location.href = response.Url;
})
}
}