This course will give you the knowledge you need to properly and effectively start integrating jQuery, the popular JavaScript library, into your web development projects. Over the course of two days, you'll learn the fundamental concepts of JavaScript and jQuery and tackle real-world exercises to solidify your understanding of the language and the library. This class is aimed at beginning jQuery users, although intermediate users may also benefit from the more formalized introduction to the library this class will offer.
8. Objects
• Booleans, strings, numbers,
arrays, and functions are all
objects
• Objects are a good way of
organizing your code
http://www.flickr.com/photos/oxido1180/2685774194/
10. Booleans (true/false)
• Lots of things are “truthy”
• true
• '0' (or any non-empty string)
•1 (or any non-zero number)
• any array, even empty ones
• any object, even empty ones
11. Booleans (true/false)
• A few things are “falsy”
• false
•0
• undefined
• null
• '' (an empty, zero-length string)
• NaN (“not a number,” the result of illegal math operations)
16. Functions
• Functions can take arguments, but they don't have to
• Functionscan return anything, including other functions -- but
they don't have to return anything
• Functions can be assigned to variables
• Functions
can be passed to other functions by name, or as
anonymous functions
• Functions are normally called by putting () after their name
25. $('a.foo').click(function(e) {
e.preventDefault();
var $this = $(this);
$this.css({ color : 'red' });
console.log('You clicked a link that points to ' +
$this.attr('href'));
});
when an a.foo link is clicked, prevent the default action,
color the link red, and tell the user where the link pointed to
31. XHR basics
• type: GET or POST
• url: a fully qualified or relative URL
• data: object or query string
• dataType: text, html, xml, json, jsonp, script
• callback: function to run when data is received
32. POST or GET?
• POST when you want to
change something on the
server
• GET when you just want to
get something from the
server
http://www.flickr.com/photos/14511253@N04/3298001461/
33. POST or GET?
• POST when you want to
change something on the
server
• GET when you just want to
get something from the
server
http://www.flickr.com/photos/14511253@N04/3298001461/
34. More options with $.ajax()
• async
• error callback
• timeout
• cache
• header modification
• more ...
http://www.flickr.com/photos/jeet_sen/1691759831/