Chapter 19 Answers
- Question 19-1
To implement an Ajax connection, YUI uses a method called
asyncRequest
, which is referenced asYAHOO.util.Connect.asyncRequest
.- Question 19-2
A callback object called
callback
for YUI, referring to a success handler calledsucceeded
and a failure handler calledfailed
, would be written like this:callback = { success:succeeded, failure:failed }
- Question 19-3
A
GET
call toasyncRequest
that refers to the programgetdata.php
and acallback
object would look like this:request = YAHOO.util.Connect.asyncRequest('GET', 'getdata.php', callback);
- Question 19-4
To encode the URL mysite.com/message?m=123, which contains the
?
symbol, so that if sent as aGET
request, it will be treated just as a string and not interpreted, use theencodeURI
method, like this:url = encodeURI("mysite.com/message?m=123")
Get Learning PHP, MySQL, and JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.