在asp.net中调用jquery ajax时出现问题

在asp.net中调用jquery ajax时出现问题,asp.net,jquery,ajax.net,parse-error,Asp.net,Jquery,Ajax.net,Parse Error,在asp.net中调用ajax jquery时,我遇到了一个奇怪的问题。。我得到了parseError,这不是预期的,因为一切都准备好了 下面是我的webmethod public class MyLogic { private int _id; public int Id { get { return _id; } set { _id = value; } } private string _title, _image;

在asp.net中调用ajax jquery时,我遇到了一个奇怪的问题。。我得到了parseError,这不是预期的,因为一切都准备好了

下面是我的webmethod

public class MyLogic
{
    private int _id;

    public int Id
    {
        get { return _id; }
        set { _id = value; }
    }
    private string _title, _image;

    public string Image
    {
        get { return _image; }
        set { _image = value; }
    }

    public string Title
    {
        get { return _title; }
        set { _title = value; }
    }
}
下面是我正在调用的方法

[WebMethod]
    public static MyLogic[] GetTopArticles()
    {
        List<MyLogic> bList = new List<MyLogic>();
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MobileKeyboardConnection"].ConnectionString);
        SqlDataAdapter adapTopStories = new SqlDataAdapter("m_sp_toparticles", con);
        adapTopStories.SelectCommand.CommandType = CommandType.StoredProcedure;
        adapTopStories.SelectCommand.Parameters.AddWithValue("@PortalId", 2);
        adapTopStories.SelectCommand.Parameters.AddWithValue("@topValue", 5);
        DataTable dtTopStories = new DataTable();
        adapTopStories.Fill(dtTopStories);
        foreach (DataRow r in dtTopStories.Rows)
        {
            MyLogic c = new MyLogic();
            c.Id = Convert.ToInt32(r["Id"]);
            c.Title = r["Title"].ToString();
            c.Image = r["image"].ToString();
            bList.Add(c);
        }
        return bList.ToArray();
    }
[WebMethod]
公共静态MyLogic[]GetTopArticles()
{
List bList=新列表();
SqlConnection con=新的SqlConnection(ConfigurationManager.ConnectionString[“MobileKeyboardConnection”].ConnectionString);
SqlDataAdapter AdapterStories=新的SqlDataAdapter(“m_sp_toparticles”,con);
AdaptiopStories.SelectCommand.CommandType=CommandType.StoredProcess;
AdaptiopStories.SelectCommand.Parameters.AddWithValue(“@PortalId”,2);
AdaptiopStories.SelectCommand.Parameters.AddWithValue(“@topValue”,5);
DataTable DTTopStores=新DataTable();
改编故事。填充(dtTopStories);
foreach(dtTopStories.Rows中的数据行r)
{
MyLogic c=新的MyLogic();
c、 Id=转换为32(r[“Id”]);
c、 Title=r[“Title”].ToString();
c、 Image=r[“Image”].ToString();
b添加(c);
}
返回bList.ToArray();
}
下面是设计图

<script type="text/javascript">
    $(document).ready(function () {
        $.ajax({
            type: "POST",
            url: "AjaxLogic.aspx/GetTopArticles",
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            data: "{}",
            success: function (data) {
                var result = data.d;
                alert(result.length);
            },
            error: function (data) {
                alert(data.responseText);
            }
        });
    });
</script>

$(文档).ready(函数(){
$.ajax({
类型:“POST”,
url:“AjaxLogic.aspx/GetTopArticles”,
数据类型:“json”,
contentType:“应用程序/json;字符集=utf-8”,
数据:“{}”,
成功:功能(数据){
var结果=数据d;
警报(结果长度);
},
错误:函数(数据){
警报(data.responseText);
}
});
});
请任何人知道可能的问题 我在应用程序中使用核心asp.net和母版页

*****************JSON响应********************

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title></head>
<body>
    <form name="form1" method="post" action="AjaxLogic.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZPKFQelTZBrnZbMRGP+4imyXfwO4" />
</div>

    <div>

    </div>
    </form>
</body>
</html>

尝试更换:

data: {},
作者:


我已经检查过了,但也不起作用,我用双引号代替了,但没有变化,这不是母版页的问题吗。。可能是吗?中是否支持ajax jquerymasterpage@Abbas,否,与母版页无关。尝试查看FireBug或Chrome开发工具中发送的AJAX请求以及服务器的确切响应。您还可以尝试从ajax请求中完全删除
数据
参数。我在firebug下检查过,它显示200 OK,但在Net-->Post-->下,它显示没有子对象。。我不知道为什么没有记录。因为我给SP打了电话,而且它给的是正确的resultset@Abbas,调试时,服务器上的PageMethod是否被命中?@Abbas,您在响应选项卡中看到了什么?发送的确切JSON是什么?
data: '{}',