我得到一個ajax錯誤,不包含'errorThrown'中的任何細節,但看着小提琴手我可以看到API調用服務器和200響應Json對象。除了Ajax錯誤,一切都運行完美。服務器得到正確的數據,並返回200Jquery Mobile Ajax來自成功的網絡api調用錯誤(返回200)
這裏是服務器端代碼
public JObject Post(JObject jobj)
{
var rtn = JsonServer.StaticJsonSrv.Post(jobj);
//force return type to Json.. trying to fix JQM problem...
JObject obj = new JObject();
obj.Add("success", "true");
return obj;
}
下面是客戶端的代碼
$.ajax({
type: 'POST',
url: URL,
dataType: 'json',
data: data,
success: function()
{
alert("Status: success");
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
//alert("Status: " + textStatus);
alert("Errors: " + errorThrown);
}
});
下面是來自服務器的結果
HTTP/1.1 200 OK
Content-Length: 18
Content-Type: application/json; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Date: Mon, 08 Apr 2013 14:13:41 GMT
{"success":"true"}
什麼是ajax錯誤? – 2013-04-08 14:27:42
爲什麼不使用dataType:'json'? – Gajotres 2013-04-08 14:33:51
@Gajotres,這是'json',但基於一個stackoverflow後嘗試解決這個問題。我把它改回到像以前一樣的json。 – 2013-04-08 14:36:03