function loaded() {
var xmldoc,
currenttime = new Date().getTime(),
req,
address = 'http://webservices.foo.com/eSignalQuotes/eSignalQuotes.asmx/GetDelayedQuotes?',
symbols = 'symbols=' + '+c,s,ct,zw,kw,adm+',
cusip = '&cusip=',
fields = '&fields=' + 'desc,month,year,recent,netchg,-decimal',
type = '&type=' + 'future,stock,index',
dispfullname = '&dispfullname=' + 'true',
datefmt = '&datefmt=',
timefmt = '&timefmt=',
timestamp = '&' + Math.floor(currenttime/3600000),
query = address + symbols + cusip + fields + type + dispfullname + datefmt + timefmt + timestamp;
;
if(window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.addEventListener('error', function(e) {alert('Error');}, false);
req.addEventListener('load', function(e) {xmldoc = req.responseText;}, false);
req.open('GET', query, true);
req.send();
}
それが私のコードのようで、SafariとFirefoxでは常にエラーが発生します。クレイジーなことは、イベントリスナーを削除し、応答タイプをに変更するとresponseText
、InternetExplorerが出力を表示することです。私は試しoverrideMimetype
ましたが、それは役に立たなかったようです。FirefoxまたはSafariで応答を確認すると、が表示されますnull
。私は途方に暮れています、そしてどんな助けもいただければ幸いです。
このためにサードパーティのライブラリを避けたいと思います。
更新:エラーはprogress
イベント中に発生します。確認する.lengthComputable
と、false
アップデート2:Safariはこの問題にさらに光を当てます:
XMLHttpRequest cannot load Origin is not allowed by Access-Control-Allow-Origin.