[英]javascript ajax call before send is not executed
I have this Javascript code: 我有这个Javascript代码:
this.confirmBox = function(data) {
$.jconfirm((function(_this) {
return function() {
var objConfig;
objConfig = $.jconfirm("getConfig");
alert("here");
return true;
};
})(this));
return false;
};
this.beforeSend = function(event, jqXHR) {
if (this.confirmBox()) {
return this.disableSubmit();
} else {
return jqXHR.abort();
}
};
When I run the script I am landing on alert("here")
and return true
for the function confirmBox. 当我运行脚本时,我将登陆到
alert("here")
并为函数ConfirmBox return true
。
The problem however is that the ajax call itself is not triggered anymore for some reason. 但是问题是,由于某种原因,不再触发ajax调用本身。 How do I need to adjust the beforeSend function in order to check if the checkBox result is true or false?
我需要如何调整beforeSend函数以检查checkBox结果是true还是false?
I think call to confirmBox method in beforeSend always returns false because $.msgbox does not block thread execution like window.confirm method does. 我认为在beforeSend中对ConfirmBox方法的调用始终返回false,因为$ .msgbox不会像window.confirm方法那样阻止线程执行。 Probably you need to invoke ajax call when you get the result === "Confirm" from message box.
从消息框中获得结果===“ Confirm”时,可能需要调用ajax调用。
$.msgbox("confirm", {
type: "confirm",
buttons: [
{ type: "cancel", value: "Cancel" },
{ type: "submit", value: "Confirm" }
]}, function(result) {
if (result === "Confirm") {
// $.ajax(..)
}
}
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.