As you can see from that function above, I call a function called "showAjaxLoader". The boolean variables are to say whether to show or hide the ajax loader. As you can see I load the ajax loader at the start of the function, then hide it at the end.
My issue is that is not what happens. There is a delay before the ajax loader is displayed rather than showing it straight away, it looks like it loads the elements and then it shows the loader.
the function for the ajaxloader looks like this:
Code:
function showAjaxLoader(isLoading, target) {
var ajaxLoader = '<div class="ajax"><img src="/Content/media/ajax-loader.gif" alt="Loading..." /></div>';
if (isLoading) {
target.css('position', 'relative');
Perhaps I'm looking at this too quickly and missing a finer point, but my guess would be that you have either the call to show the AJAX loader or hide the AJAX loader in the wrong place. I don't actually see any AJAX request code in there and obviously you want to show the AJAX loader before the request is made. Then using the readyState attribute you'd of course wait for the request to be complete and then execute some code to handle the responseText and finally hiding the AJAX loader.
So wherever the AJAX request is, you'll want your showAjaxLoader() function to appear before the .send() in your request. After the readyState is equal to 4 (meaning the request is complete of course) you'd probably then execute your createList() function which seems to handle the data; at the end of this function you'd then be hiding your AJAX loader.