2014-04-26 94 views
0
$.ajax({ 
    type: "GET", 
    contentType: "text/html; charset=utf-8", 
    url: "secret.aspx", 
    data: { 
     plu: $("#Text1").val(), 
     gh: $("#TextBox1").val(), 
     sid: $("#TextBox2").val() 
    }, 
    dataType: "html", 
     success: function(data) { 

      $("#result").html(data); 
           } 
    }); 

我打電話給aspx頁面,呼叫正常進行。數據輸入數據庫中,但值不返回頁面從ajax呼叫沒有收到數據

返回語句如下:

Response.Write("hello"); 
Response.End(); 
+0

您正在返回什麼'數據類型?嘗試返回'(「

hello

」)' – Coderaemon

回答

0

它應該工作。也許secret.aspx發生錯誤。爲了找出答案,請在ajax調用中添加error設置,以便了解任何錯誤。您還可以添加警報來顯示返回的數據,以防與您的result元素有關:

   success: function (data) { 
        alert(data); 
        $("#result").html(data); 
       }, 
       error: function (xhr, ajaxOptions, thrownError) { 
        alert(xhr.status + ' - ' + xhr.responseText); 

        alert(thrownError); 
       } 
      });