1
我正在使用AJAX和ASP.NET Web方法加載一些內容。以下是對Ajax代碼:Ajax在啓用URL重新路由後停止工作
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();
}
的代碼工作正常,直到我啓用了URL重寫,改變了規則包含頁網頁的方法來ContentViewer/{view}
(即TopicList.aspx
)。
現在web方法不被AJAX調用。
請幫忙!