更新时间:2023-11-20 23:32:16
好了,根据关使用的$不用彷徨函数返回的XmlHtt prequest对象的建议我想出了这一点:
Ok, so based off of the suggestion to use the XmlHttpRequest object returned by the $.get function I came up with this:
function doStuff(){
var ajaxRequest = $.ajax({
url : 'url/url/url',
type : "GET",
success : function(data){
ajaxRequest = null;
doSuccessStuff(data);
}
});
$('#dialog').dialog({
title: 'Stuff Dialog',
bgiframe: true,
modal: true,
buttons: {
Cancel: function() {
if (ajaxRequest)
ajaxRequest.abort();
doCancelStuff();
}
}
});
}
看来工作和清洁的感觉给我。
It seems to work and feels cleaner to me.