我在网上搜索了IE9 ajax跨域问题的许多解决方案,但找不到任何解决方案。
我用于ajax调用的url看起来像这样(这是跨域,因为我的域名看起来像www.domain.com):
"http://some.domain.com/folder//api/12c63101-5d02-ab70-6e2a-4519ed75a0fd/rename?accept=json"
ajax调用如下所示:(我尝试添加/删除crossDomain / type以及我能想到的任何内容)
$.ajax({
url:url,
dataType:'json',
type: 'POST',
crossDomain: true,
success:function(data){}
complete : function(data) {}})
这是来自chrome的可爱回复(此次请求应该失败):
{errorCode: -3997, errorDescription: "[runtime][RECOVERABLE] failed, name [] taken", success: false, payload: null}
但这是来自IE9的奇怪反应
LOG: {
readyState : 0,
setRequestHeader : function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},
getAllResponseHeaders : function(){return s===2?n:null},
getResponseHeader : function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},
overrideMimeType : function(a){s||(d.mimeType=a);return this},
abort : function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this},
done : function(){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this},
fail : function(){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this},
progress : function(){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this},
state : function(){return e},
isResolved : function(){return!!e},
isRejected : function(){return!!e},
then : function(a,b,c){i.done(a).fail(b).progress(c);return this},
always : function(){i.done.apply(i,arguments).fail.apply(i,arguments);return this},
pipe : function(a,b,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=b[0],e=b[1],g;f.isFunction(c)?i[a](function(){g=c.apply(this,arguments),g&&f.isFunction(g.promise)?g.promise().then(d.re,
promise : function(a){if(a==null)a=h;else for(var b in h)a[b]=h[b];return a},
success : function(){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this},
error : function(){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this},
complete : function(){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this},
statusCode : function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},
status : 0,
statusText : "No Transport"
}
(当我尝试将其解析为JSON时,IE9响应在代码中触发SCRIPT1014: Invalid character
,因为它显然不是JSON ...)
与“无运输”有关?有跨域问题?
UTF-8? (已经宣布$.ajaxSetup({ scriptCharset: "utf-8" , contentType: "application/json; charset=utf-8"});
我没有希望 - 有人可以建议吗?
答案 0 :(得分:1)
尝试设置:
jQuery.support.cors = true; // force cross-site scripting (as of jQuery 1.5)
看看它是否有帮助。