2012-07-10 47 views
2

我寫了一個web方法,它有字符串返回value.this返回值獲取表單存儲過程。但是當條件未被建立時undefined值returned.i寫下面的代碼但它沒有工作在ajax-jquery中識別web方法獲取的返回值

$.ajax(
               { 
type: "POST", 
    url: "WebForm1.aspx/confirm", 
    data: JSON.stringify({ 
    username: username, 
    password: password, email: email,codemeli: codemeli}), 
    contentType: "application/json; charset=utf-8", 
    dataType: "json", 

     async: true, 
     cache: false, 
     success: function (ret) { 

      if (ret != "") { 
      $('#result').text(ret.d + " : " + "it is reserved "+ret.lenght); } 
      else { $('#result').text("the operation is successful"); } 
     }, 
     error: function (x, e) { 
     $('#result').text(x.responseText); 
      } 
      } 
     ); 

回答

4

ret.lenght應該是ret.d.lengthsuccess回調。

+0

我這樣做,但它返回undefined仍然 – quantum62 2012-07-10 07:18:51

+0

在哪一行你會得到這個錯誤? – 2012-07-10 07:23:05