I have an ActionController that takes two parameters, both integers.
public ActionResult DisplayQuestions(int categoryId, int page) {
...
}
When a user pushes right or left, my page directs the user to another page. When the user has reached the end of th开发者_开发知识库e pages, i would like to redirect him to a new category, which the action controller can load.
$(document).keydown(function (e) {
var code = (e.keyCode ? e.keyCode : e.which);
var currentPage = $("#CurrentPage").val();
var numberOfPges = $("#NumberOfPages").val();
if (code == 39) {
if (currentPage < numberOfPges) {
// Næste side
changePage(parseInt(currentPage) + 1);
$(document).focus();
}
else {
// Send user to the next category
// $("#nextCategory")
}
}
else if (code == 37) {
// Tilbage
if ((parseInt(currentPage) - 1) != 0) {
changePage(parseInt(currentPage) - 1);
$(document).focus();
}
else {
// Send user to the previous category
// $("#previousCategory")
}
}
});
Basically i would like to call the ActionController with the values of either
$("#nextCategory")
or
$("#nextCategory")
and page = 1
The JavaScript is in the same ActionController as the View displaying it.
I.E
/Survey2/DisplayQuestions?categoryId=2&page=1
I want to update the whole page. What is the best way to do it?
Thanks!
You can use jQuery post or jQuery submit for this.
in your else statement you'll have something similar to this
//Send user to the next category
$.post( "/somepath/someaction", "#nextCategory" );
精彩评论