2014-04-26 96 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); 
       } 
      });