jquery - Pattern for AJAX Form Submissions in ASP.NET MVC -


here able do:

  1. display dialog box containing form create new record (for example user)
  2. form submitted via ajax.
  3. get response can either same form validation errors or new record in json format.

some additional information:

  • i using partials render form. when dialog first displayed make ajax call empty form markup , when form submitted use same partial if form has validation errors.
  • if response comes , there validation errors want replace existing form markup returned markup.
  • if response comes , there not validation errors close dialog , take json formatted object , make other changes page.

i parts of working fine. problem if pass json formatted object on success instead of html can definition never sure return type be. first though return json ajax calls. if form had validation errors returned json have property called "html" contain updated form markup. if there not validation errors returned json have property called "data" contains newly created object.

i think solution work, wonder if else has come more elegant. imagine basic flow must common in other applications, can't 1 looking solution problem.

you mentioned you'd add client-side validation... need way display validation errors in client-code. if have that, instead of returning html ajax call, can instead return list of validation errors in json, , plug same error-display methods have client validation.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -