I have a query that is quite long and takes a few seconds to display the results. It is an ajax call to an external script. How can I display a loading message inside of the div, but have the loading message disappear once the results are displayed?
Her开发者_C百科e is the function: >
function findstore(){
var txt = 'Please enter the zip code to find the closest store <input type="text" name="zipcode" id="zipcode">';
$.prompt(txt,{
buttons:{Confirm:true, Cancel:false},
submit: function(v,m,f){
var flag = true;
if (v) { }
return flag;
},
callback: function(v,m,f){
if(v){
var zipcode = f.zipcode;
$.post('findstore.php',{zip:zipcode},
function(data){
$("div#demo").html(data);
}
);
}
}
});
}
>
In your logic you can load the animated gif inside the just before calling your callback method. You can associate the button cick with the code needed to load the gif into the div.
Then as soon as you get data back (inside function(data){}
) you can remove the gif by replacing the content of the with the returned data.
精彩评论