ajax请求后台没有返回需要的信息
1.JS代码:
function JudgeHasCommunity() {
var value = $("#" + '<%=TextBox5.ClientID%>').val();
var data = encodeURI(value) ;
var reg=/^[\u0391-\uFFE5]+$/;
if (!reg.test(value)) {
alert("必须为中文字符");
return false;
}
else {
$.ajax({
type: "GET",
url: "CheckCommunity.aspx",
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
data: "cName=" + data,
beforeSend: function (XMLHttpRequest) {
$("#" + '<%=showResult2.ClientID%>').text("正在查询");
//Pause(this, 100000);
},
success: function (msg) {
$("#" + '<%=showResult2.ClientID%>').html(msg);
$("#" + '<%=showResult2.ClientID%>').css("color", "red");
},
complete: function (XMLHttpRequest, textStatus) {
//隐藏正在查询图片
},
error: function () {
//错误处理
}
});
}
}
2.页面控件:
<td>
您所在的社区:
</td>
<td>
<asp:TextBox ID="TextBox5" runat="server" onblur="JudgeHasCommunity();"></asp:TextBox>
</td>
<td><asp:Label ID="showResult2" Style="float: left" runat="server" Text=""></asp:Label></td>
3.CheckCommunity.aspx.cs:
public partial class CheckCommunity : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string cName = Request["cName"].ToString();
List<T_Community> lt = CommunityManager.GetCommunityBycName(cName);
if (lt != null)
{
Response.Write("您可以使用此社区名!");
}
else
{
Response.Write("社区名不存在!");
}
}
}
问题:在CheckCommunity.aspx.cs的Page_Load处设置完断点,然后在文本框中输入社区名称,是数据库中有的社区名称,而且在调试的时候也能得到list记录 是不为空的,照理应该是返回"您可以使用此社区名!"这个msg 然后在showResult2处显示,现在只显示“正在查询”,没有显示结果,为什么,小弟菜鸟一个。。。。请高手帮忙解答