0
我試圖從服務器獲取響應,但我得到空狀態。我哪裏錯了? 我想從腳本發送到Max4live補丁內的服務器。當發送Json對象時,XMLHttpRequest返回狀態0
var xhr = new XMLHttpRequest();
var url = 'myURL'
log("1");
xhr.open('PUT', url, true, 'myUser', 'myPass');
log("2");
xhr.setRequestHeader('Content-Type', 'application/json');
log("4");
xhr.send(JSON.stringify(JsonExport));
log("5");
log("Status: "+xhr.status+ " "+xhr.statusText);
if (xhr.status == 4) {
var userInfo = JSON.parse(xhr.responseText);
log("Status");
log(xhr.responseText);
log(userInfo);
} else {
log("Response");
log(xhr.responseText);
}
//log(xhr.responseType["json"]);
delete xhr;
我得到就行了:日誌( 「狀態: 」+ xhr.status +「」 + xhr.statusText): 狀態:0零 ...這裏我想獲得一個json對象來自服務器。任何想法? 謝謝!