show ajax loader image while making ajax request with jquery

You will need an image, first. Go to and get one you like.

Put the html for the loader in the page.

<div id="spinner">
    <img src="/jobadmanager/Content/images/ajax-loader-big.gif" alt="Loading..."/>

Style the div element to position it on the centre of the browser.

    display: none;
    height: 100px;
    position: fixed;
    top: 50%;
    left: 50%;
    margin-left: -50px;
    margin-top: -100px;
    overflow: auto;

Now, use javascript to fade it in and out, when an ajax request starts.

<script type="text/javascript">
    $('#spinner').ajaxStart(function () {
    }).ajaxStop(function () {



show ajax loader image while making ajax request with jquery

Disable browser cache for ajax request on ASP.NET MVC

The application reloads the list of jobs, if any job is reposted or expired. We display different labels, such as “reposted”, “expired”, depending on the action. It worked well with browsers but IE 8.

Simply, IE was cacheing the part of html. Though we request the partial view by post.

update: function () {
        type: "GET",
        url: "MJobsB?p=" + list.cPg(),
        contentType: "text/html; charset=utf-8",
        dataType: "html",
        success: function (data) {
            $('#ct #cnt').html(data);
        error: function () { alert("Error Loading Jobs"); }

So, we brought in NoCache attribute. And made the action not cached on IE. We made it with attribute, as we want to cache other stuff, especially images.

This is NoCache attribute.

public class NoCacheAttribute : ActionFilterAttribute
    public override void OnResultExecuting(ResultExecutingContext filterContext)


On controller, you just add the attribute.

public ActionResult MJobsB(int cId, int? pg)
    return RenderJobListIn("_MJobsB", cId, Mode.List, pg, false);            
Disable browser cache for ajax request on ASP.NET MVC