---
title: "How to add loader in mvc?"  
description: "How to add loader in mvc?"  
author: "Sunil Singh"  
published: 2017-06-24  
updated: 2017-06-27  
canonical: https://www.mindstick.com/forum/34315/how-to-add-loader-in-mvc  
category: "asp.net mvc"  
tags: ["asp.net", "asp.net mvc", "mvc"]  
reading_time: 1 minute  

---

# How to add loader in mvc?

I want to show [Loader](https://www.mindstick.com/forum/156609/create-loader-with-bootstrap) when [button is clicked](https://www.mindstick.com/forum/157821/write-a-jquery-code-that-selects-all-the-checkboxes-in-a-form-when-a-select-all-button-is-clicked) before [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) is displayed.

Below is my [view](https://yourviews.mindstick.com/view/84701/layoffs-in-google-india-2023-view) [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) I don’t know what should be the [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc) code and jquery.

Please help me.

```
<body>   
@using (Ajax.BeginForm("Loader", "Home", new AjaxOptions { HttpMethod = "POST",}))   
{       
<input type="submit" value="Please click" />   
}    
<div id="divLoading">      
   
</div>    
<div id="target">      
   
</div></body>
```

## Replies

### Reply by Sushant Mishra

**Controller code**

```
       public ActionResult Ajax()        {            return View();        }        public ActionResult Loader()        {            System.Threading.Thread.Sleep(5000);            return PartialView("PartialView");        }
```

View code

```
@{    Layout = null;} <!DOCTYPE html> <html><head>    <meta name="viewport" content="width=device-width" />    <title>Ajax</title>      <script src="~/Scripts/jquery-3.1.1.min.js"></script>    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>    <script type="text/javascript">        function onBegin() {            $("#divLoading").html('<image
src="../Images/loader.gif" alt="Loading, please wait"
/>');        }        function onComplete() {            $("#divLoading").html("mindstick
software");        }    </script></head><body>    @using (Ajax.BeginForm("Loader", "Home", new AjaxOptions { UpdateTargetId = "target", OnBegin = "onBegin", OnComplete = "onComplete" }))    {        <input type="submit" value="Please
click"
/>    }     <div id="divLoading">           </div>     <div id="target">           </div></body></html>
```


---

Original Source: https://www.mindstick.com/forum/34315/how-to-add-loader-in-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
