2010-10-28 83 views
1

我處於這種情況,我無法弄清楚我錯在哪裏。 我打電話使用,因爲它叫jquery.It工作正常進行的WebMethod的操作。但它調用功能服務的Web服務失敗的比成功的$ error從句阿賈克斯調用

應該提醒我「嗨」如果服務successfule.but它調用ServiceFailed功能,但在數據庫中的值更新完全當我進入並通過使用$就調用服務

我Ĵ查詢代碼是休耕

功能ActionSendRequest(){

 if (globArray.length > 0) { 
      alert(globArray.length); 
      document.getElementById('lblError').innerHTML = 'Please Wait.....'; 
      for (var i = 0; i < globArray.length; i++) { 
       var Lot = globArray[i]; 
       var Price = document.getElementById('prc' + globArray[i]).value; 
       var Quantity = document.getElementById('qty' + globArray[i]).value; 
       $.ajax({ 
        type: "POST", 
        url: "../test.asmx/AddModReqSample", 
        data: "{Lot:'" + Lot + "',Price:'" + Price + "',Quantity:'" + Quantity + "'}", 
        contentType: "application/json; charset=UTF-8", 
        dataType: "xml", 
        processdata: true, 
        success: function (msg) { 
         ServiceSucceeded(msg); 
        }, 
        error: ServiceFailed 
       }); 
      } 
     } 
    } 
    function ServiceSucceeded(result) { 
     alert('hi'); 
     if (result.d == "Error") { 

     } 
     else if (result.d == "Successfully") { 

     } 
    } 
    function ServiceFailed(result) { 
     document.getElementById('lblError').innerHTML = 'Service call failed: ' + result.status + '' + result.statusText; 
    } 

而且我的web服務方法是休耕

[的WebMethod(EnableSession =真)]

公共字符串AddModReqSample(INT地段,小數價格,小數數量) {

 if (SessionLog.UID != 0) 
     { 
      return objDataStore.ReqSample(Lot, SessionLog.UID, Quantity,Price); 

     } 
     else return "Please Login to the System"; 

} 的我得到的最終消息就是這樣的 服務呼叫失敗:200 OK

回答

1

在查看響應和代碼後r更多的時間,我得到了問題,我的webmethod響應在JSON格式,而我正在尋找數據的XML格式,因爲你可以看到在上面的代碼 dataType:「xml」,我改變爲JSON,現在我得到它正確。 感謝每一個