I am interested in creating an AJAX form submit in a jQuery overlay. I am not sure how to approach this, do I just toss a partial view into the overlay?
I want to pass to the server the data in the form of a model so I can save it the the data base, I need to be able to create some sort of indication as to whether or not the request succeed. Can anyone guide me through this?
I am kinda new with AJax.
You could use jQuery UI Dialog. For example let’s suppose that you have a view model:
and a controller:
In this example the Index action will serve the main view which will simply contain a link allowing to show the form as a modal dialog.
Here’s the
Index.cshtmlview:and the
Modal.cshtmlpartial which will contain the form:The last step is to wire everything using javascript. Here are the 2 callbacks used:
and that’s it.
Don’t forget to reference the jquery-ui and jquery.unobtrusive-ajax scripts to your page: