$(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方法是访问到了的,我确定。

解决方案 »

  1.   

     [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);
         }后台是是这样的
      

  2.   

    $(document).ready(function(){
      alert(1);//这句能正确弹出来的
    })
      

  3.   


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

  4.   


    不是这个原因吧?
    这个是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();
            }
      

  5.   


    jQuery.getJSON(url,data,callback)