Suppose I have a form :
<form id="myForm" method="POST" action="/something/somewhere">
<input type="text" name="textField" />
<input type="submit" name="foo" value="bar" />
</form>
the /something/somewhere action does not return a complete html page, but just a fragment.
I would like to let the submit button do its posting job, but catch the result of this post and inject it somewhere in the DOM.
The jQuery submit happens before the form is actually submitted. An exemple of how it could work is:
$('#myForm').posted(function(result)
{
$('#someDiv').html(result);
});
Any way to do this?
Description
You can use the jQuery
.post()and.serialize()method for that.Sample
Html
jQuery
MVC Controller
If you have trouble getting it to work (thanks IE), try
More Information