I am working with a large project that is built with ASP.NET MVC 5.
I have a Wait Cursor that I want to display whenever a query is run. Some queries are called with jQuery syntax:
`$.get("@Url.Action("BigQuery", "Home"));`
But most are called with Html.BeginForm syntax:
`@using (Html.BeginForm("BigQuery", "Home", FormMethod.Post))`
Using the jQuery syntax, I can show and hide the Wait Cursor:
```
$(document).ready(function () {
$('#waitDiv').hide();
$(document).ajaxStart(function () {
$('#waitDiv').show();
})
$(document).ajaxStop(function () {
$('#waitDiv').hide();
});
});
```
But, these methods are not triggered with the Html.BeginForm, and they account for over 90% of the calls in the corporate website.
What can I do to allow the Wait Cursor to show and hide with the Html.BeginForm techniques?

Tuhin PaulPosted Feb 18, 2023, 5:31 AM
Html.BeginForm syntax are used to make different types of requests. Html.BeginForm is used to submit a form and load a new page. The $(document).ajaxStart() and $(document).ajaxStop() methods are triggered when an asynchronous request is made and completed respectively, which is why they work with the jQuery syntax.
To show the wait cursor for Html.BeginForm requests, you can use the jQuery submit() method to intercept the form submission and show the wait cursor. You can add a class to the form that triggers the wait cursor, then remove the class when the form is submitted. Here's an example:
In Html.BeginForm, add the class show-wait-cursor to the form element:
this is going to trigger the submit() method when the form is submitted, which will show the wait cursor and remove the show-wait-cursor class from the form. When the page is loaded after the form is submitted, the wait cursor will be hidden.
Try and see if it works in your case. let me know.
Naimish MakwanaPosted Feb 17, 2023, 4:17 AM
Hello joe,
For all the form please try below approch.
Or you can use ajaxSend method.
Thanks
Naimish Makwana
Joe PoolPosted Feb 16, 2023, 7:42 PM
@Naimish Makwana - Can that same ID be used for all of my Views? I have 159 .cshtml Views that I would have to add an ID to. If they are not unique, then the jQuery will need to address each form's Submit routine by ID.
Sorry, but I don't really know how to post a follow-up comment to your answer.
Pasang TamangPosted Feb 16, 2023, 5:45 AM
Hi,
You can use Ajax.BeginForm to use ajax functionality on form post. You can check below links for examples
https://www.c-sharpcorner.com/UploadFile/0c1bb2/ajax-beginform-in-Asp-Net-mvc-5/
https://www.aspsnippets.com/Articles/ASPNet-MVC-AjaxBeginForm-Tutorial-with-example.aspx
Regards,
Pasang
Naimish MakwanaPosted Feb 16, 2023, 4:01 AM
Hello Joe,
To show and hide the Wait Cursor with the
Html.BeginFormmethod, you can do the following things.1. Give ID to you form. Ex :
2. You can do code in jQuery like this:
Thanks
Naimish Makwana