C# Ajax在启用URL重新路由后停止工作

C# Ajax在启用URL重新路由后停止工作,c#,javascript,jquery,asp.net,ajax,C#,Javascript,Jquery,Asp.net,Ajax,我正在使用AJAX和ASP.NET web方法加载一些内容。以下是Ajax的代码: var pageIndex = 1; var pageCount; $(window).scroll(function () { if ($(window).scrollTop() == $(document).height() - $(window).height()) { GetRecords(); } }); function GetRecords() { page

我正在使用AJAX和ASP.NET web方法加载一些内容。以下是Ajax的代码:

var pageIndex = 1;
var pageCount;

$(window).scroll(function () {
    if ($(window).scrollTop() == $(document).height() - $(window).height()) {
        GetRecords();
    }
});
function GetRecords() {
    pageIndex++;
    if (pageIndex == 2 || pageIndex <= pageCount) {
        $("#loader").show();
        $.ajax({
            type: "POST",
            url: "TopicList.aspx/GetTopics",
            data: '{pageIndex: ' + pageIndex + '}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: OnSuccess,
            failure: function (response) {
                alert(response.d);
            },
            error: function (response) {
                alert(response.d);
            }

        }
        );

    }
}
function OnSuccess(response) {
    var xmlDoc = $.parseXML(response.d);
    var xml = $(xmlDoc);
    pageCount = parseInt(xml.find("PageCount").eq(0).find("PageCount").text());
    var topics = xml.find("Topics");

    topics.each(function () {
        var table = $("#dvTopics table").eq(0).clone(true);

        var topic = $(this);
        $.ajax({
            type: "POST",
            url: "TopicList.aspx/LoadTopicRow",
            data: "{message: '" + topic.find("desid").text() + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (r) {
                table.append(r.d);
            }
        });
        $("#dvTopics").append(table);

    });

    $("#loader").hide();
}
var-pageIndex=1;
var pageCount;
$(窗口)。滚动(函数(){
if($(窗口).scrollTop()==$(文档).height()-$(窗口).height()){
GetRecords();
}
});
函数GetRecords(){
pageIndex++;

如果(pageIndex==2 | | pageIndex由于您没有包含任何错误的详细信息,这是一个不确定的结果。请尝试更改您的url 发件人:

url: "TopicList.aspx/LoadTopicRow",
url: "TopicList/LoadTopicRow",