Stephen Woodbridge wrote:
> Dmitrii 'Mamut' Dimandt wrote:
>
>> Mike Alsup wrote:
>>
>>>> $.ajaxStart() is invoked for every ajax call that's made on the page.
>>>>
>>>> However, for one ajax call I need to display a "loading..." in one
>>>> place, for another ajax call - a "loading..." in another place and for
>>>> yet a third ajax call a "loading" in a third place.
>>>>
>>>> How can I do this in jQuery? Preferably, in one line (true to jQuery
>>>> spirit :)) ).
>>>>
>>>>
>>> You may want to use ajaxSend instead ajaxStart. ajaxSend is passed
>>> the xhr and the settings object for the ajax call. This should give
>>> you the context you need to figure out where the loading indicator
>>> should go.
>>>
>>> $().ajaxSend(function(e, xhr, settings) {
>>> // your code
>>> });
>>>
>>> Mike
>>>
>>>
>>>
>> Still. This is still like a proctologist performing an eye surgery :))
>> Big thanks for the tip, though!
>>
>>
>
> I think you need to define your problem in more detail if you want
> concrete help with it.
>
> Like, how do you plan to identify and differentiate the different
> "loading" locations and respective messages? How is the first, second
> and third place identified in the DOM or in you code, or in your mind?
> Do you have a metadata structure that defines these that can be used to
> pull information from? etc. How do each of these separate ajax requests
> get initiated? What would your code look like if you didn't have the
> "loading" messages running.
>
> If you ask really abstract questions you should probably expect to get
> abstract responses because we can only guess at your needs. I'm sure the
> list will help if there is enough information.
>
> This sounds like an interesting problem that others might run into.
>
> -Steve
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
For instance, I have an ajax-powered poll, an ajax-powered search and an
ajax-powered login form. I would rather have a "loading..." text to
appear in each of those components instead of a single "loading..."
somewhere on the page (like gmail does, for instance - i hate that :) ).
So I would really like to do something like:
function search()
{
$.load(
$("myid"),
url,
params,
{
onStart: function(){searchLoader.show();},
onEnd: function(){searchLoader.hide();}
}
);
}
function pollSubmit()
{
$.post(
$.post(
url,
params,
{
onStart: function(){pollLoader.show();},
onEnd: function(){pollLoader.hide();}
}
);
)
}
etc...
I guess I'll have to write a plugin :))
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/