Nic Hubbard wrote:
> I have a number of GET and POST ajax calls that do various things my
> script. For each one, I would like to set a status that is a string,
> so that I can out put that to the user. So, it might look like this:
>
> Ajax POST
> Posting to page
>
> Ajax GET
> Getting content page
>
> Ajax POST
> Sending data to page
>
> Basically I want to set the status using something like $
> ('#status_div').text(); so that the user will see the status text when
> each ajax function is run.
>
> Does anyone have ideas on how this could be accomplished?
>
This is what I used to do:
1. In the click function handler, put the loading text and image to the
status placeholder.
$('#status_div').html('<img src="loading.gif" /> Loading ...');
2. Call the ajax
3. In the ajax callbak function, I update the status placeholder with
the ajax response message
$.post(url
,{param: "value"}
,function(r){
$('#status_div').html(r.message);
}
, "json");
The complete code will be like this:
$(trigger).click(function(){
$('#status_div').html('<img src="loading.gif" /> Loading ...');
$.post(url
,{param: "value"}
,function(r){
$('#status_div').html(r.message);
}
, "json");
});
You can adjust this according to your need. This is what I like to do in
my code (and my client so far happy with it) :)
--
Donny Kurnia
http://hantulab.blogspot.com
http://www.plurk.com/user/donnykurnia