在Safari浏览器(mac和windows)中进行jquery ajax调用(jquery版本1.8.3)时,我们遇到了一些奇怪的行为,其中调用的onSuccess部分在实际url调用完成之前执行。当我们提取具有200状态的Developer工具时,我们看到调用被返回,但由于代码执行直接跳转到onSuccess,因此数据无法呈现。我们不会在IE,Chrome,Firefox中遇到任何此类问题。我们发现,如果您单步执行/调试代码,它就永远不会发生。只有在我们以发布模式运行它时才会发生。我们认为它与异步调用有关,但显然无法验证。调用返回204状态代码。任何建议/见解将不胜感激。
提前致谢!
//private methods
function callService(url, verb, args, version, successCallback, errorCallback, publishMethodName) {
$.ajax({
url: url
, type: verb
, data: args
, accepts: { json: "application/json;V=" + version + ";Persist=" + cfn.core.services.persist + ", text/javascript" }
, contentType: "application/json; charset=utf-8" // content type sent to server
, dataType: "json" //Expected data format from server
, processdata: true
, success: function (result) {
if(successCallback != null)
successCallback(result, publishMethodName);
}
, error: function (xhr) {
if (errorCallback == null)
serviceFailed(xhr, window.location.href, url, verb, version, publishMethodName);
else {
serviceFailed(xhr, window.location.href, url, verb, version, publishMethodName);
errorCallback(xhr);
}
}
});
} //callService