第一次用JQUERY,回调函数不执行

xxmiaoyong126com 2010-06-28 04:05:03

$(document).ready(function(){
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "web_check_i_check.aspx/detail",
data: "{theid:'" + id + "'}",
dataType: 'json',
async: true, //ajax异步
success: function(data) {
alert(1);
}
});
}
)

为什么不会有alert弹出来的?
后台的detail方法是访问到了的,我确定。
...全文
152 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
KK3K2005 2010-06-28
  • 打赏
  • 举报
回复

jQuery.getJSON(url,data,callback)
l6801567 2010-06-28
  • 打赏
  • 举报
回复
路过。。。
xxmiaoyong126com 2010-06-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 lieri111 的回复:]

JScript code

alert("1");//应该加引号
[/Quote]

不是这个原因吧?
这个是datatable转字符串的方法
public static string ToJsonArr(DataTable dt)
{
StringBuilder jsonString = new StringBuilder();
jsonString.Append("[");
DataRowCollection drc = dt.Rows;
for (int i = 0; i < drc.Count; i++)
{
jsonString.Append("[");
for (int j = 0; j < dt.Columns.Count; j++)
{
string strKey = dt.Columns[j].ColumnName;
string strValue = drc[i][j].ToString();
Type type = dt.Columns[j].DataType;

strValue = StringFormat(strValue, type);
if (j < dt.Columns.Count - 1)
{
jsonString.Append(strValue + ",");
}
else
{
jsonString.Append(strValue);
}
}
jsonString.Append("],");
}
jsonString.Remove(jsonString.Length - 1, 1);
jsonString.Append("]");
return jsonString.ToString();
}
iey000 2010-06-28
  • 打赏
  • 举报
回复
楼上的回答好简洁
passself 2010-06-28
  • 打赏
  • 举报
回复

alert("1");//应该加引号
xxmiaoyong126com 2010-06-28
  • 打赏
  • 举报
回复
$(document).ready(function(){
alert(1);//这句能正确弹出来的
})
xxmiaoyong126com 2010-06-28
  • 打赏
  • 举报
回复
[WebMethod]
public static string detail(string theid)
{
string sql = "select * from h_checks where pid='"+theid+"'";
Sqlserver db = new Sqlserver();
DataTable dt = db.select(sql);
return csharpjson.ToJsonArr(dt);
}

后台是是这样的

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧