I have ajax call of action in the controller, after it update the database and it is completed successfully I can do like this:
return PartialView("Overview", mydatamodel);
and then in the the success to do like this:
success: function (data) {
// do something with the data => refresh some
// portion of your DOM
$('#someDivId').html(data);
}
And it would work fine, but what I need is that a collection in the view model to be updated, and the whole view to be rendered again with the new data.
I can do that if for instance I have submit button, then whole view is updated with the new data but if I have ajax call, how can i do that.
Here is link to my previous post where have more details:
MVC3 receiving the new model data after submit
Thank you in advance!
If you want to update the entire view don’t use AJAX. Simply use a submit button. The whole point of AJAX is to update only a portion of the view without navigating away from the current page.
By the way you could redirect on the client side using
window.location.href:but there’s really no need to do that if you will always redirect in the success AJAX callback. You should not use AJAX in this scenario.