5. JQUERY MICRO TUTORIAL
// jQuery is...
// a function you can call to query or create DOM elements:
var old_element = $(‘#some > .css[selector]’);
var new_element = $(‘<div id=”hello”><span>world</span></div>’);
6. JQUERY MICRO TUTORIAL
// This function always returns an array-like collection with
// lots of convenient chain-able methods.
$(‘#target’)
.empty()
.append(new_element);
9. JQUERY MICRO TUTORIAL
// jQuery is also...
// a collection of useful utilities (not chain-able)
var a = [0, 1, 2, 3];
$.each(a, function(i, val) {
alert(‘Index ‘ + i + ‘ has value ‘ + val);
});
var b = $.isArray(a);
10. JQUERY MICRO TUTORIAL
// ajax: load directly into element
$(‘#target’).load(‘file.html’);
// fine-grained control
$.ajax({
url : ‘file.html’,
type : ‘POST’,
async : false,
success: function(data, status, jqXHR) {
// handle response
}
});
12. 1.5 IMPROVEMENT:
AJAX
• complete rewrite
• implemented as a “deferred
object”
13. NEW 1.5 FEATURE:
DEFERRED OBJECTS
A deferred object is a chainable utility object that can register
multiple callbacks into callback queues, invoke callback queues,
and relay the success or failure state of any synchronous or
asynchronous function.