i have the following jquery code. basically - it takes a value from an anchor - and displays a sub-menu content below it. this works perfectly.
$(function(){
$('.plus').live('click', function(event){
event.preventDefault();
$(this).addClass('lower');
var existingPath = $(this).attr('rel');
GetSubs(this, existingPath);
$(this).removeClass('plus').addClass('open'); //.delay(10000).removeClass('lower');
});
function GetSubs(IDclicked, existingPath){
var dataString;
dataString = 'lang=<%=Lang%>&rel=[' + existingPath + ']';
$.ajax({
type: "GET",
url: "/includes/getSubCatMenuLinks.asp",
data: dataString,
success: function(data) {
$(data).insertAfter(IDclicked);
},
error: function(obj,msg) {
alert('*** Error! ***\n\n'+msg);
}
});
}
});
what i would like to do - is have a a "loading" icon showing, while the content is loading - and then remove it when done.
displaying it is fine - thats whats done in the line
$(this).addClass('lower');
when a few lines down, i try remove that class - but the movemext is so fast - that the loading icon doesnt even show. ie - the ajax content hasnt appeared yet, but the jquery code has already loaded the class, loaded the ajax (somewhere) and then removed the class - so the loading icons doesnt even display.
i tried using the delay method - to have it removed a seconds or a few later - but it doesnt work.
any help appreciated!
thanks!
successcallback of yourGetSubsfunction.