<script type="text/javascript"> $(function () { $.ajax2 = function (options) { var img = $("#progressImgage"); var mask = $("#maskOfProgressImage"); var complete = options.complete; options.complete = function (httpRequest,status) { img.hide(); mask.hide(); if (complete) { complete(httpRequest,status); } }; options.async = false; /* img.show().css({ "position": "fixed","top": "50%","left": "50%","margin-top": function () { return -1 * img.height() / 2; },"margin-left": function () { return -1 * img.width() / 2; } }); */ img.show().animate({ position: "fixed",top: "50%",left: "50%",marginTop:function () { return -1 * img.height() / 2; },marginLeft: function () { return -1 * img.width() / 2; } },3000 ); mask.show().css("opacity","0.1"); $.ajax(options); }; }); </script> $.ajax2({ url: url,data:"contentId="+contentId,success:function(data){ var last_mb20Temp = $(".mb_20:last"); last_mb20Temp.after(data); mbIndex = $(".mb_20").index(last_mb20Temp); } }); <img id="progressImgage" class="progress hide" alt="" src="/${res}/img/images/loading.gif" /> <div id="maskOfProgressImage" class="mask hide"></div>