To be particular, in ASP.Net MVC project, I want to show loading image using jQuery when my form post to the server and next action method gets called, as post login, it takes too much time to load the next page.
I tried onclick() javascript method on submit button:
<input type="submit" onclick="jsFunction()">
Also the onsubmit() method of form:
<form onsubmit="jsFunction"> ... </form>
or
@using (Html.BeginForm("Save", "ReadingsEntry", FormMethod.Post, new { onsubmit = "jsFunction()" }))
{
In case of both, both gets called even there are local validation errors.
I have to show loading img only when the form the getting submitted to server post satisfying the local validation errors.
Any idea in what way this can be achieved?
submitevent through jQuery, not using the outdatedon*event attributes. Then, assuming you're using unobtrusive validation, it will work fine.