I can do this with straight forward posts to different controllers/actions. Say I had a list of orders and when select an order I get the order in edit mode, how would I do this with jquery(i.e. no post backs etc all on the one page) and post the edit and return to the list. I want to still use the data annotations etc for validation. Cheers.
Asked
Active
Viewed 203 times
1 Answers
0
I am assuming you are using Spring MVC. I have accomplished this by using the $.ajax()
function and serializing the Spring-bound form with the jQuery Form Plugin. See example below:
Create a container <div id="container"></div>
around your Spring MVC form.
$.ajax({
type: 'POST',
url: actionUrl,
data: $('#id_of_your_form_tag').serialize(),
success: function(data) {
$('#container').html(data);
},
async: false
});

izilotti
- 4,757
- 1
- 48
- 55
$.get( '@Url.Action("details","user", new { id = Model.ID } )', function(data) { $('#detailsDiv').replaceWith(data); }); One thing about is how do I pass the id. To go back to my original example. I have a list of orders and the above code displays the edit form. How does the above jquery know the model.id to use the above example? See http://stackoverflow.com/questions/1570127/render-partial-view-using-jquery-in-asp-net-mvc – user1102550 Dec 28 '12 at 19:29