Pops,
The function that you bind to the ajaxComplete event actually takes 3
arguments. So yes, the documentation is wrong. The three arguments
are:
1. The event object
2. The XHR
3. The settings object
$().ajaxComplete(function(ev, xhr, s) {
alert('event type: ' + ev.type);
alert('status: ' + xhr.status);
alert('url: ' + s.url);
});
Functions bound to the ajaxSend and ajaxSuccess events work exactly
the same way as ajaxComplete.
Functions bound to the ajaxError event are passed a fourth argument
which is the exception object (if one occurred).
Functions bound to the ajaxStart and ajaxStop events are passed only a
single argument, the event object.
Mike
On 8/14/07, Pops <[EMAIL PROTECTED]> wrote:
>
> I'm still a newbie with jQuery, as such, I'm still catching up with
> terminologies and the jQuery "language"
>
> Exploring the ajaxComplete() event handler, it seems to me that the
> prototype description of its callback function parameters are reverse?
>
> For example, the docs for ajaxComplete( callback ) says:
>
> Attach a function to be executed whenever an AJAX
> request completes. The XMLHttpRequest and settings
> used for that request are passed as arguments to the callback.
>
> with the example:
>
> $("#msg").ajaxComplete(function(request, settings){
> $(this).append("<li>Request Complete.</li>");
> });
>
> well, for my test, under the FireBug Debugger I stepped into this
> callback and it says request is type "Object" and settings is type
> "XMLHttpRequest"
>
> Is this an example type, the parameters should be (settings, request)
> or I am not understanding?
>
> I'm sure I am understanding, but when I modified the example for my
> testing of using $.getJSON(), like so:
>
> JSON: <div id="JsonDump"></div>
>
> <script type='text/javascript'>
> $(document).ready(function() {
> var url = "/code/jSystemMonitor.wcx";
> var secs = 5000;
> $("#JsonDump").ajaxComplete(function(request, settings){
> $(this).append("<li>"+settings.responseText+"</li>");
> });
> var res = $.getJSON(url);
> setInterval( function() { var res = $.getJSON(url); }, secs);
> });
> </script>
>
> I naturally thought and used request.responseText instead of
> settings.responseText first before seeing it this was wrong. Maybe the
> parameter name "setting" is not appropiate. I used to libraries where
> function prototyping descriptions convery ideas like Hungarian
> notations or similar ideas that allow to quickly understand the
> parameters types with a visual reading only: I had to dig into the
> jQuery.js source to see what exactly was being passed and even then it
> wasn't clear.
>
> Overall, is there a documented summary showing the function prototype
> definitions for all various jQuery methods that offer callbacks?
>
>