I want to display loading animation when the user clicks on submit button. Simple gif will do the job. This is my code:
@using (Html.BeginForm("SData","Crawl"))
{
<p>
Enter Starting URL:<input class="txt" type="text" id="sUrl" name="sUrl" title="Enter Starting URL"/>
</p>
<p>
Enter Number of Threads:<input class="txt" type="text" id="Nbt" name="Nbt" title="Enter number of threads"/>
</p>
<p>
<input class="button" id="submit" type="submit" value="Submit" />
</p>
}
Edit
I mistakenly thought the question concerned the AJAX helper. Here's how you could do it using the HtmlHelper.
First, add an ID to the form so you can grab it using JQuery:
Next, add a Javascript event handler to intercept the form submission and display the loading GIF.
(Original answer follows...)
Use the
AjaxOptions
class to set aLoadingElementId
, and the Ajax helper will display that element while waiting for the response from the server:Then simply place your gif wherever you want it to display (hide it initially):
Hello I just read your post here and it worked fine for me in .net core 2.1 using Microsoft.AspNetCore.Mvc:
then the HTML script:
if you have problems you might want to debug your Action Method and see if it breaks inside the statement.... @Dr Freeman: you are able to redirect to any view as follows:
Hope this help