0
我正在使用JSONP通過AJAX從API收集數據。我已經在firefox和chrome中測試了我的代碼,並且在這些瀏覽器中完美運行。Internet Explorer中的Jsonp回調無法正常工作
鏈接我使用的格式如下:
www.placeholder.com/foo/?jsonp=dataCallback
然而,當我試圖做同樣的事情在Internet Explorer 11我得到一個錯誤說:
對象不支持屬性或方法「dataCallback」
我注意到,在Firefox和Chrome,窗口將包含一個名爲「dataCallback」當我執行請求的對象。但是,在Internet Explorer 11中,當執行請求時,窗口中不存在「dataCallback」這樣的東西。
$.support.cors = true;
$.ajax({
url: url,
dataType: "jsonp",
contentType: "application/javascript",
crossDomain: true,
async: true,
cache: true,
// Work with the response
complete: function (response) {
var data = window["dataCallback"]();
callback(self.parseData(data, scope, end), transport);
}
});
我這個已知的問題?我該如何解決它?