2013-04-08 38 views
0

我得到一個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"} 
+0

什麼是ajax錯誤? – 2013-04-08 14:27:42

+0

爲什麼不使用dataType:'json'? – Gajotres 2013-04-08 14:33:51

+0

@Gajotres,這是'json',但基於一個stackoverflow後嘗試解決這個問題。我把它改回到像以前一樣的json。 – 2013-04-08 14:36:03

回答

0

我在IE中運行它,並且出現無傳輸錯誤。搜索,給了我一個解決方案'No Transport' Error w/ jQuery ajax call in IE

$.support.cors = true; 
+0

這是一個跨域問題.. – 2013-04-18 15:23:35

+0

我最終使用代理服務器,跨域是一個問題,我似乎無法輕鬆解決。 – 2013-05-02 19:04:17

相關問題