SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 184 | Next

Jonathan Snook, Aaron Gustafson, Stuart Langridge, and Dan Webb

"Accelerated DOM Scripting with Ajax, APIs, and Libraries"

The second
parameter is the URL to request. The third parameter is a callback object. The object stores
the success and failure callback functions as well as enabling you to pass arguments into the
call to be available upon return.
var callback = {
success: myObject.processRequestSuccess,
failure: myObject.processRequestFailure,
argument: [argument1, argument2, argument3],
scope: myObject
}
You can also specify the scope that should be passed to the function calls. That way, if the
success and failure callbacks are part of a larger object, you can maintain the scope for the
this variable.
If performing a POST request, you can pass the data in with a query string format as a
fourth parameter:
var transaction = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback,a
'key1=encoded+data&key2=even+more+data');
The YUI library even has a nice function to take all form fields and automatically append
them into a request (removing the need to specify the fourth parameter):
YAHOO.util.Connect.setForm(formObject);
var conn = YAHOO.util.Connect.asyncRequest('POST', 'http://example.com/', callback);
jQuery
jQuery is heavily designed around manipulating the DOM. Its Ajax approach takes the Prototype
Ajax.Updater to another level:
$('#myelement').load('/updatestatus');
As you saw in the last chapter, the $ function grabs the elements (in this case, an element
with an ID of myelement).


Pages:
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
druga wojna światowa Free English grammar and study guid hotel jelenia góra Russian bride counter strike 1.6