Documentation for second parameter to AJAX callbacks.

12 views
Skip to first unread message

Richard Quadling

unread,
Jun 2, 2010, 11:15:05 AM6/2/10
to prototy...@googlegroups.com
Hi.

I'm pretty sure I'm missing it, but where is the documentation about
the second parameter to the AJAX callbacks please?

The second parameter contains the headerJSON value (or null).

Has this facility been dropped?

http://api.prototypejs.org/ajax/ajax/request/ (scroll down to
Evaluating JSON headers) doesn't mention it.

It is mentioned on http://api.prototypejs.org/ajax/ajax/responders

So, for example, what happens for onSuccess() ?

As far as I can tell, it works just the same.

Regards,

Richard.

--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

Allen Madsen

unread,
Jun 2, 2010, 11:59:29 AM6/2/10
to prototy...@googlegroups.com
Hi Richard,

I may be misunderstanding what you are asking, but the documentation
doesn't mention a second parameter. Rather, it says the headerJSON is
a property on the first parameter passed into your onSuccess/onFailure
methods.

Hope that helps!

Allen Madsen
http://www.allenmadsen.com

> --
> You received this message because you are subscribed to the Google Groups "Prototype: Core" group.
> To post to this group, send email to prototy...@googlegroups.com
> To unsubscribe from this group, send email to prototype-cor...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en

Tobie Langel

unread,
Jun 2, 2010, 6:06:40 PM6/2/10
to Prototype: Core
It's been deprecated in favor of Ajax.Response#headerJSON.

Best,

Tobie

Richard Quadling

unread,
Jun 4, 2010, 6:43:38 AM6/4/10
to prototy...@googlegroups.com
> --
> You received this message because you are subscribed to the Google Groups "Prototype: Core" group.
> To post to this group, send email to prototy...@googlegroups.com
> To unsubscribe from this group, send email to prototype-cor...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en

Allen,

From http://api.prototypejs.org/ajax/ajax/responders :

"The callbacks for responders are similar to the callbacks described
in the Ajax section, but take a different signature. They're invoked
with three parameters: the requester object (i.e., the corresponding
"instance" of Ajax.Request), the XMLHttpRequest object, and the result
of evaluating the X-JSON response header, if any (can be null). They
also execute in the context of the responder, bound to the this
reference."

but the normal callbacks are only documented with the response parameter.

Tobie,

Where?

Current git trunk still has it that the second parameter is response.headerJSON

http://github.com/sstephenson/prototype/blob/master/src/ajax/request.js#L293
(onXYZ, onSuccess/onFailure dispatch)
http://github.com/sstephenson/prototype/blob/master/src/ajax/request.js#L307
(Responder dispatching)

It may be just a case of the code and the documentation not agreeing
and no comments saying that the second parameter is deprecated.

Tobie Langel

unread,
Jun 4, 2010, 4:28:07 PM6/4/10
to Prototype: Core
> It may be just a case of the code and the documentation not agreeing
> and no comments saying that the second parameter is deprecated.

Right on. I also wasn't aware it was documented for Responders. We
never marked it deprecated for ajax callbacks, as it never actually
was documented.

Best,

Tobie

Richard Quadling

unread,
Jun 5, 2010, 5:19:04 PM6/5/10
to prototy...@googlegroups.com

This whole exercise has been useful though.

I didn't quite get the difference between headerJSON and responseJSON.
Both of which are extremely useful.

headerJSON for the status (data retrieved, errors, etc.) and
responseJSON the the content (data, error messages, etc.) from the
server side app.

Excellent stuff!

Tobie Langel

unread,
Jun 5, 2010, 6:54:06 PM6/5/10
to Prototype: Core
> headerJSON for the status (data retrieved, errors, etc.) and
> responseJSON the the content (data, error messages, etc.) from the
> server side app.

Yes, headerJSON is particularly useful combined to HTML in the
response body.
Reply all
Reply to author
Forward
0 new messages