Javascript jQuery AJAX函数在IE中运行不正常?
我在这里挠头已经有一段时间了,所有版本的IE似乎都有这个电话的问题。这里有几条重要信息:Javascript jQuery AJAX函数在IE中运行不正常?,javascript,jquery,ajax,post,Javascript,Jquery,Ajax,Post,我在这里挠头已经有一段时间了,所有版本的IE似乎都有这个电话的问题。这里有几条重要信息: 值是一个数据对象,我可以验证它是否有数据 所有window.trigger函数都用于Google analytics跟踪,它们在代码的其他几个部分中使用,不会出现问题 在IE中,函数的间隔似乎很奇怪,所有其他函数都正确排列,但这个函数的排列似乎很奇怪,这让我怀疑是否有什么地方不对 success函数似乎未运行,failure和statusCode函数被完全忽略。这让我想知道这是否不是jQuery方法的问题,
我猜缓存有问题。IE自动缓存ajax请求。要克服此问题,请在$.ajax代码中设置选项
cache:false
示例:
function createLead(values) {
var url = "/api/v1/createlead/?apikey=XXXX-XXXX-XXXX-XXXX";
//debugger;
$.ajax({
type : "POST",
contentType : "application/x-www-form-urlencoded; charset=UTF-8",
url : url,
data : values,
success: function (result) {
result = $.parseJSON(result);
if (result.redirect) {
$(window).trigger('googleEvent' , 'regFailure');
window.location.href = values.returnUrl;
return;
}
else if (result.status === "OK" ) {
if (result.data.isPixelToBeFired){
$(window).trigger('googleEvent' , 'pixelFire');
}
else {
$(window).trigger('googleEvent', 'noPixelFire');
}
olp_sLeadId = result.data.leadId;
olp_sPathId = result.data.pathId;
$(window).trigger('googleEvent', 'regSuccess');
window.location = "path.html?curPathId=" + olp_sPathId
+ "&curLeadId=" + olp_sLeadId; // Enter the path
}
else {
// console.log('FAIL' , result , values);
$(window).trigger('googleEvent' , 'regFailue');
window.location.href = values.returnUrl;
return;
}
},
statusCode: {
404: function() {
$(window).trigger('googleEvent' , 'createLead404');
window.location.href = values.returnUrl;
//console.log('Something is seriously wrong');
return false;
}
},
failure: function (result) {
$(window).trigger('googleEvent' , 'createLeadFailure');
window.location.href = values.returnUrl;
//console.log('Something is seriously wrong');
return false;
}
});
}
希望这会有帮助
$.ajax({
type : "POST",
contentType : "application/x-www-form-urlencoded; charset=UTF-8",
url : url,
data : values,
cache : false,
// existing stuff
});