Reputation: 93
I currently have a product list that includes reviews from users where you can navigate trough the reviews with next and previous button. But currently it goes to a hole new page url like pageid=2, I'd like to have a script that doesn't need to go to a new url but just loads the new page of reviews in the current page. Could someone share a code snippet for this? Because i have no idea how i could make this as i don't have experience with javascript/jquery.
Thanks for your help!
Upvotes: 0
Views: 199
Reputation: 194
Suppose you have anchor tags with class set as "paging" 1 2 . .
$(".paging").click(function(){
var PageID=$(this).text();
$.get("Review/GetReview/"+ PageID ,function(data,status){
$("#ReviewContainer").html(data);
});
});
This will call your Action Method "GetReview" from controller "Review" with parameter as ID. And set the html content.
Hope this will help you! Thanks.
Upvotes: 0
Reputation: 11
Create a partial view called Reviews, make an Ajax post/get request to your action within your controller that returns your partial view, within the success method of your jquery Ajax request, you will need to place the rendered HTML into a div container, ie, $('#mydiv').html(data).
http://api.jquery.com/jQuery.get/
Upvotes: 1