Maintaing page number of MVC 2 pagination on refresh
I'm using MVC 2 Pagination (not the jquery one) and my partial page gets refreshed in every 5 second.
I 开发者_如何学运维want to maintain my page number on refresh. Can you please suggest me how that can be done.
Here is the code for the page refresh in every 5 sec
setInterval(function () {
$.ajax(
{
type: "GET",
url: '<%=Url.Action("divtobeupdated", "DefaultController") %>',
data: {},
dataType: "text",
success: function (result) { $("#FileListContainer").html(result); }
}
)
}, 5000);
you can try 2 solution:
1) you pass the number of the page to the server and you pass it back to the view(no so good because you hace to change many code) 2) set a javascript global variable and you set it in the setInterval, like this:
var numOfPage;
setInterval(function () {
numOfPage = getNumofPage();
$.ajax(
{
type: "GET",
url: '<%=Url.Action("divtobeupdated", "DefaultController") %>',
data: {},
dataType: "text",
success: function (result) {
//heare you can use numOfPage
$("#FileListContainer").html(result);
}
}
)
}, 5000);
I hope understund good your question.
Marco
精彩评论