in a asp.net web application, I am using AJAX to submit a form.
I want to run a javascript code before submitting it.
So I did this:
@using (Ajax.BeginForm("SaveProductDetails", "Store", new AjaxOptions
{
HttpMethod = "Post",
LoadingElementId = "progress",
OnBegin = "BeforeSubmit()",
OnSuccess = "closeMe()",
OnFailure = "doAlert('An error occurred while trying to save your changes. Please contact your Administrator')"
}))
But the problem is that After running the BeforeSubmit() function the submit is stopping. the form is not submitting.
There is no problems with the BeforeSubmit() function.
If I dont do anything with the OnBegin, the form submits properly.
Any help is greatly Appreciated.
You can do something like below.
View code