CS50 - Week 8
JavaScript
References
https://developer.mozilla.org/en-US/docs/JavaScript/Guide
Method - a function which is inside of a variable
Nameless / anonymous / lambda functions - functions which don't have a name but can be called.
document.getElementById('registration').onsubmit = function() {
// do stuff;
// return true to continue submission, false to stop
};
jQuery
$("#map-canvas")
returns a jQuery object (with lots of functionality built in)
$("#map-canvas").get(0)
returns the actual underlying DOM node which jQuery is wrapping
Ajax example
function quote() {
var url = "quote.php?symbol=" + $('#symbol').val();
$.getJSON(url, function(data) {
$('#price').html(data.price);
});
}