[jQuery] Question about use of $.ajaxStart(callback)
Hello,
Do you absolutely have to use the global event ajaxStart to process
code only when an Ajax query starts, or there's a way to pass it as a
parameter (either via an undocumented feature or 3rd party plugin) to
the $.ajax() function? I can't seem to find any answer on this
anywhere...
I've written a javascript function that is wrapped around $.ajax since
I need to call many different things using Ajax in my site (makes it
easier to control some events). The thing is, there is no optional
parameter for $.ajax() that I can pass to tell it what to do when the
ajax starts. So I *have to* use the $.ajaxStart global event, which
means I need to bind it to an element (which I do not necessarily
want), and that I have to unbind it if another query needs to touch
another element on ajaxStart... Sometimes, the timing of ajax request
"success" events make this very difficult when it shouldn't be...
I love using the $ajax() function as it's very easy to customize to
what I need, but wouldn't it be better if you could pass it a
parameter for each event type and not just beforeSend, complete,
success and error? I'm sure I'm not the only one that wish he could do
that at the local scope (events only affecting that query and no
other).
It would also be nice to have a callback event available
for .abort()... which you can sort of get using a well known plugin,
but it would be better if it could be part of the core itself.
Did I miss something or is it really something that is missing?