I have a very basic email submission form in my ASP.NET MVC 3 app. I'm trying to integrate the jQuery form plug-in with it.
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.form.js")"></script>
<script type="text/javascript">
// prepare the form when the DOM is ready
$(document).ready(function () {
var options = {
beforeSubmit: showRequest,
success: showResponse
};
// bind form using 'ajaxForm'
$('#mailform').ajaxForm(options);
});
function showRequest(formData, jqForm, options) {
alert('request');
}
// post-submit callback
function showResponse(responseText, statusText, xhr, $form) {
alert('response');
}
</script>
...
<form action="@Url.Action("SubmitEmail")" class="mail-form" id="mailform" method="post">
<fieldset>
<span class="txt">
<input type="text" name="email" id="email" value="Enter Your Email Address" />
</span>
<input class="button" id="submitemail" type="submit" />
</fieldset>
</form>
I've tested my non-AJAX version and it works just fine. When I try to use the jQuery plug-in, however, the showRequest function gets called, but the showResponse function doesn't-- and it doesn't seem like the method is ever called on the server either.