为什么ajax回调无法执行success而是error
ajax代码如下:vartxtname=document.getElementById("ctl00_ContentPlaceHolder1_txtuser").valu...
ajax代码如下:
var txtname=document.getElementById("ctl00_ContentPlaceHolder1_txtuser").value;
if (txtname != "") {
jQuery.ajax({
type: "GET",
url: "adcheckusera.aspx",
data: "u=" + txtname,
dataType: "json",
success: function(msg) {
alert(msg.du);
//
},
error: function(e) {
alert(e);
}
})
}
后台代码:
protected void Page_Load(object sender, EventArgs e)
{
string uname = this.getRequest("u");
string retxt = "";
string sql = "select username from webuser where username = '" + uname + "'";
DataTable dt = AccessDB.GetTable(sql);
if (dt.Rows.Count == 1)
retxt = "t";
else
retxt = "f";
string returntxt = "{\"du\":\"" + retxt + "\"}";
Response.Write(returntxt);
}
后台的retxt也能正常赋值为t或f,但是ajax却回调为error里的函数,输出的alert为[object xmlhttprequest] 展开
var txtname=document.getElementById("ctl00_ContentPlaceHolder1_txtuser").value;
if (txtname != "") {
jQuery.ajax({
type: "GET",
url: "adcheckusera.aspx",
data: "u=" + txtname,
dataType: "json",
success: function(msg) {
alert(msg.du);
//
},
error: function(e) {
alert(e);
}
})
}
后台代码:
protected void Page_Load(object sender, EventArgs e)
{
string uname = this.getRequest("u");
string retxt = "";
string sql = "select username from webuser where username = '" + uname + "'";
DataTable dt = AccessDB.GetTable(sql);
if (dt.Rows.Count == 1)
retxt = "t";
else
retxt = "f";
string returntxt = "{\"du\":\"" + retxt + "\"}";
Response.Write(returntxt);
}
后台的retxt也能正常赋值为t或f,但是ajax却回调为error里的函数,输出的alert为[object xmlhttprequest] 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询