asp.net mvc 3 - Submit with a jQuery Prompt -


let's have generic jquery prompt asks me rename element , tells me entered:

$(function () { $("#rename").click(function () {     jprompt('please enter new name:', 'enter new name...', 'rename prompt', function (r) {         if (r) {             alert('you entered ' + r);         }     }); }); }); 

but element wish rename stored on database on server, means need run server-side script rename element. assume means need use submit, on form. i've found information .submit() jquery function here not entirely understand how works. if let me know how make submit , run server-side script appreciated.

$(function () {     $("#rename").click(function (e) {         e.preventdefault();         jprompt('please enter new name:', 'enter new name...', 'rename prompt', function (r) {             if (r) {                 $('input[name="newname"]').val(r.name);                 $.post('@url.action("edit", "thecontroller")', $('#hiddenform').serialize(), function(response) {                     // response = actionresult                 });             }         });     }); }); 
  1. use url.action correct uri
  2. use prevent default block default action
  3. return kind of json mvc3 action indicate success/failure.
  4. place hidden <form> somewhere , fill information post

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -