0
我試圖將以下json發送到web方法。螢火蟲報告以下錯誤:嘗試使用JQuery發送JSON時出現Parse錯誤Ajax()
XML Parsing Error: no element found Location: moz-nullprincipal:{d9dc6bef-4ec9-4899-b8df-7319db0e47cf} Line Number 1, Column 1:
我編輯請求報頭包含內容類型。有人可以幫我嗎??
var request = {"uid":"Test","application":",myApplication","localization":"en-us","id":"aae49326","context":"","clientToken":"puttokenhere2","version":"2.0.87","timestamp":"4/6/2011 13:15:57","status":"COMPLETED","data":""};
jQuery.ajax({ beforeSend: function(xhrObj) {
xhrObj.setRequestHeader("Method", "POST");
xhrObj.setRequestHeader("Content-Type", "application/json; charset=\"utf-8\";");
},
async: false,
type: "POST",
contentType: "application/json; charset=\"utf-8\";",
dataType: "json",
url: MILESTONEURL,
data: request,
complete: function(response, status) {
if ("success" == status) {
alert("SUCCESS:\n" + response.responseText);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
var response = eval("(" + XMLHttpRequest.responseText + ')'); ;
alert("FAILED:\n" + XMLHttpRequest.responseText);
}
});
}
問題是在web服務 - 1號線收盤
行情是完全有效的。這也是JSON對它們進行編碼的方式。 – Alnitak 2011-04-06 21:22:21