[jQuery] Re: Request for a simple basic Ajax call with loading gif

2008-02-18 Thread johan . borestad

var loader = $('div.ajaxloader').fadeIn(500)

$('#ajax-placeholder').load('/content_to_load.php', function(){
// This is a callback function
loader.fadeOut(500)
})

Something like that.

The div.ajaxloader is for you to style correctly with css to make it
appear in the middle of the page, or wherever you wan't it.
Just a basic example

/ Johan


On 18 Feb, 09:18, gh0st [EMAIL PROTECTED] wrote:
 One of the things that is frustrating me in learning jQuery is that
 there isn't enough examples, case-studies or tutorials on how to use
 the .ajax call; most web pages I've seen seem to be for the .load
 or .get.

 That being said, can someone post a very basic Ajax call complete with
 a loading gif?

 Also, does anyone have any links/resources to case-studies/examples of
 Jquery and the .ajax call?

 With thanks.


[jQuery] Re: Request for a simple basic Ajax call with loading gif

2008-02-18 Thread Remy Sharp

I've written a few, but there's a whole bunch out there (http://
docs.jquery.com/Tutorials).

Using Ajax to validate forms:

http://jqueryfordesigners.com/using-ajax-to-validate-forms/

Ajax'ifing forms (screencast):

http://remysharp.com/2007/03/05/jquery-ajaxed-forms/

What you're after boils down to this (though very simply):

$('#waitingblock').html('img src=loading.gif /');

$.ajax({
  url: 'myurl.php',
  data: 'action=do-stuff',
  success: function () {
$('#waitingblock').empty(); // remove the loading image
// do stuff.
  },
  error: function () {
$('#waitingblock').empty();
// let the user know something went wrong
  }
});

On Feb 18, 8:18 am, gh0st [EMAIL PROTECTED] wrote:
 One of the things that is frustrating me in learning jQuery is that
 there isn't enough examples, case-studies or tutorials on how to use
 the .ajax call; most web pages I've seen seem to be for the .load
 or .get.

 That being said, can someone post a very basic Ajax call complete with
 a loading gif?

 Also, does anyone have any links/resources to case-studies/examples of
 Jquery and the .ajax call?

 With thanks.