SlideShare a Scribd company logo
1 of 33
LESSON FOUR
    jQuery intro
Fast Review
Functions = “First Class Objects”
Anonymous Functions

     function() {
      // code goes here
      }
Arrays


data structure for ordered values
   var team = [‘ben’,‘jeff’,‘kam’];
   team[0] // => ‘ben’
Objects



collections of “key/value” properties
  var person = {};
  person.name = ‘will’;    // Write
  var name = person.name; // Read
Document Object Model
Review Homework
Enter, jQuery
What is jQuery

Framework for using Javascript to interact with
the browser
•   Simple DOM API: manipulate HTML / CSS on the page

•   Simple AJAX API: send and receive data from the server

•   Simple Event API: do stuff when the user does stuff

•   Thats it!
What is a Framework?

                    A library of utility functions

Small                  Medium                   Large
•   Underscore.js       •   jQuery UI       •    YUI (Yahoo UI)
•   jQuery              •   MooTools        •    GWT (Google web toolkit)
•   Prototype.js        •   Dojo            •    EXT JS (commercial)



      there are LOTS of them for web development
Why use jQuery
•   The DOM API is _nasty_!

•   Cross browser

•   Fast - Faster than raw DOM manipulation! *magic*

•   Lightweight (31kb)

•   Stable and trusted

•   Required for many other frameworks

•   EVERYBODY uses it
Include jQuery
<script src="/js/jquery.js"></script>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/
jquery.min.js"></script>



                         Try it out!
jQuery Syntax
  or…how to follow the $

$(document).ready(function(){
  // Your code here
});




    DOM Manipulation
   $("a").addClass("test");
using jQuery
Selecting Elements
                      Using CSS!


$("#foo")     // the [element] at id “foo”


$(".bloop")   // the [elements] with class “bloop”


$("a.buzz")   // the [links] with class ‘buzz’



$(".bloop:first")      // specialty! The first bloop!


=>   :hidden, :visible, :last, :checked, :empty,       :odd...
Important Methods
.show() / .hide() / .toggle()
   $(".swap_text").toggle();


.addClass(".active")
.removeClass(".active")


.css(key, value)
   $("#my_box").css(‘backgroundColor’,   ‘red’);
   $("#my_box").css({

            ‘backgroundColor’ : ‘red’,
            ‘color’ : ‘#030’
   });
Important Methods

.animate(properties, duration, callback)

   $(‘#my_box’).animate({
            ‘backgroundColor’ : ‘red’,
            ‘marginTop‘         : ‘20px’,
            ‘color‘             : ‘#030’
   }, 3000, justFinished);   // execute the animation for 3 seconds
                             // and when done, call: justFinished();
Important Methods

.html() / .val() / .attr(‘attribute’)

   $(‘#my_title’).html(); // returns the innerHTML

   $(‘#my_title’).html(“New Title!”); // sets the innerHTML



   $(‘input#email’).val(“please enter your email address...”);



   $(‘img’).attr(“src”, “placekitten.com/30/30”);



                             as before: these methods can get or set...
Methods Can “Chain”




$("#my_box").addClass(‘inactive’).removeClass(‘active’).hide();
jQuery Events

$(document).ready()     // the DOM is loaded
window.load()           // all elements (including images)
                           have loaded


.change()
.submit()
.focus()
.click
.scroll()
.hover()
.keypress()                                ...And so many more!
Events w/o jQuery
                      no browser consistency




EX:


.addEventListener("click", function({}) );   // Firefox


.attachEvent("onclick", function({}) );      // Internet Explorer
jQuery Insertion




.append()
.after()
.insertAfter()
.before
.insertBefore()
.clone()
Client Side
   Requests
[XHR and AJAX]
XMLHttpRequest




Allows you to make a web request via client side javascript
Invented by Microsoft for Internet Explorer, then ported to other
browsers

   var request = new XMLHttpRequest(); // Create new request object
   request.open(“GET”, “path/file.ext”, false); // “open” the request
   request.send(null); // Make the request
   var text = request.responseText; // Check the response text
BUZZZZWORD




“XHR”
•   XMLHttpRequest

•   Misnomer => Not limited to XML data

•   By default, synchronous
AJAX




By default, XHR proceeds synchronously
In other words, your code will hang until the request is complete
What if you want your code to keep executing?
   => Use AJAX
BUZZZZWORD



“AJAX”
•   “Asynchronous Javascript and XML”

•   XHR done asynchronously

•   Provide a callback to execute when the request is complete

•   Changed the face of web development => page reloads no longer
    required to add new content to a page
AJAX via DOM



var request = new XMLHttpRequest(); // Create new request object
request.open(“GET”, “path/file.ext”, true); // ‘True’ => AJAX

request.send(null); // Make the request
var text = request.responseText; // Will be null this time!
request.onreadystatechange = function() {
 if (request.readyState == 4) {
     // Request is done. Can check responseText
 }
AJAX via DOM



var request = new XMLHttpRequest(); // Create new request object
request.open(“GET”, “path/file.ext”, true); // ‘True’ => AJAX


          CONFUSING this time!
request.send(null); // Make the request
var text = request.responseText; // Will be null
request.onreadystatechange = function() {
 if (request.readyState == 4) {
     // Request is done. Can check responseText
 }
AJAX via jQuery



    $.ajax({
  url: "test.html",
  success: function(return_text){
    $("#results").append(return_text);
 }
});




                          more next week...
QUESTIONS?
contact will_and_bay@hackyale.com

More Related Content

What's hot

jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009Remy Sharp
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoiddmethvin
 
jQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and BlingjQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and BlingDoug Neiner
 
Unobtrusive javascript with jQuery
Unobtrusive javascript with jQueryUnobtrusive javascript with jQuery
Unobtrusive javascript with jQueryAngel Ruiz
 
A Short Introduction To jQuery
A Short Introduction To jQueryA Short Introduction To jQuery
A Short Introduction To jQuerySudar Muthu
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuerymanugoel2003
 
Jquery Best Practices
Jquery Best PracticesJquery Best Practices
Jquery Best Practicesbrinsknaps
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery PresentationRod Johnson
 
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby DeveloperVenturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby DeveloperJon Kruger
 
Testable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScriptTestable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScriptJon Kruger
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery EssentialsMark Rackley
 
Don't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQueryDon't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQueryshabab shihan
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQueryZeeshan Khan
 

What's hot (20)

jQuery Introduction
jQuery IntroductionjQuery Introduction
jQuery Introduction
 
jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 
jQuery
jQueryjQuery
jQuery
 
jQuery
jQueryjQuery
jQuery
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoid
 
jQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and BlingjQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and Bling
 
Unobtrusive javascript with jQuery
Unobtrusive javascript with jQueryUnobtrusive javascript with jQuery
Unobtrusive javascript with jQuery
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 
A Short Introduction To jQuery
A Short Introduction To jQueryA Short Introduction To jQuery
A Short Introduction To jQuery
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Jquery Best Practices
Jquery Best PracticesJquery Best Practices
Jquery Best Practices
 
The Beauty of Java Script
The Beauty of Java ScriptThe Beauty of Java Script
The Beauty of Java Script
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery Presentation
 
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby DeveloperVenturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
 
D3.js and SVG
D3.js and SVGD3.js and SVG
D3.js and SVG
 
Testable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScriptTestable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScript
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
 
Don't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQueryDon't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQuery
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 

Viewers also liked

Metodología de Investigación "Comunicative Daile Life Stories"
Metodología de Investigación "Comunicative Daile Life Stories"Metodología de Investigación "Comunicative Daile Life Stories"
Metodología de Investigación "Comunicative Daile Life Stories"Vanessa Costa
 
Application 1785686
Application 1785686Application 1785686
Application 1785686Vishal Shah
 
2007 bpc conference
2007 bpc conference2007 bpc conference
2007 bpc conferenceguest56b4f0
 
Lives of the Great War: Building First World War life stories across archives...
Lives of the Great War: Building First World War life stories across archives...Lives of the Great War: Building First World War life stories across archives...
Lives of the Great War: Building First World War life stories across archives...Museums Computer Group
 
State of the LexBlog Address 2016 - Slides from LexBlog's Webinar
State of the LexBlog Address 2016 - Slides from LexBlog's WebinarState of the LexBlog Address 2016 - Slides from LexBlog's Webinar
State of the LexBlog Address 2016 - Slides from LexBlog's WebinarLexBlog, Inc.
 

Viewers also liked (6)

Metodología de Investigación "Comunicative Daile Life Stories"
Metodología de Investigación "Comunicative Daile Life Stories"Metodología de Investigación "Comunicative Daile Life Stories"
Metodología de Investigación "Comunicative Daile Life Stories"
 
Application 1785686
Application 1785686Application 1785686
Application 1785686
 
2007 bpc conference
2007 bpc conference2007 bpc conference
2007 bpc conference
 
Lives of the Great War: Building First World War life stories across archives...
Lives of the Great War: Building First World War life stories across archives...Lives of the Great War: Building First World War life stories across archives...
Lives of the Great War: Building First World War life stories across archives...
 
Alexis Willey
Alexis Willey Alexis Willey
Alexis Willey
 
State of the LexBlog Address 2016 - Slides from LexBlog's Webinar
State of the LexBlog Address 2016 - Slides from LexBlog's WebinarState of the LexBlog Address 2016 - Slides from LexBlog's Webinar
State of the LexBlog Address 2016 - Slides from LexBlog's Webinar
 

Similar to Week 4 - jQuery + Ajax

A Rich Web experience with jQuery, Ajax and .NET
A Rich Web experience with jQuery, Ajax and .NETA Rich Web experience with jQuery, Ajax and .NET
A Rich Web experience with jQuery, Ajax and .NETJames Johnson
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for JoomlaLuke Summerfield
 
A Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETA Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETJames Johnson
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsEPAM Systems
 
jQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyjQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyHuiyi Yan
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksJavascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksHjörtur Hilmarsson
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on AndroidSven Haiges
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenerytoddbr
 

Similar to Week 4 - jQuery + Ajax (20)

A Rich Web experience with jQuery, Ajax and .NET
A Rich Web experience with jQuery, Ajax and .NETA Rich Web experience with jQuery, Ajax and .NET
A Rich Web experience with jQuery, Ajax and .NET
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for Joomla
 
jQuery
jQueryjQuery
jQuery
 
A Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETA Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NET
 
Jquery fundamentals
Jquery fundamentalsJquery fundamentals
Jquery fundamentals
 
JavaScript JQUERY AJAX
JavaScript JQUERY AJAXJavaScript JQUERY AJAX
JavaScript JQUERY AJAX
 
J query training
J query trainingJ query training
J query training
 
jQuery for web development
jQuery for web developmentjQuery for web development
jQuery for web development
 
jQuery: Events, Animation, Ajax
jQuery: Events, Animation, AjaxjQuery: Events, Animation, Ajax
jQuery: Events, Animation, Ajax
 
Unit3.pptx
Unit3.pptxUnit3.pptx
Unit3.pptx
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript Basics
 
jQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyjQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journey
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksJavascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & Tricks
 
Introducing jQuery
Introducing jQueryIntroducing jQuery
Introducing jQuery
 
22 j query1
22 j query122 j query1
22 j query1
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introduction
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
JQuery UI
JQuery UIJQuery UI
JQuery UI
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery Fundamentals
 

Recently uploaded

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Recently uploaded (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

Week 4 - jQuery + Ajax

  • 1.
  • 2. LESSON FOUR jQuery intro
  • 4. Functions = “First Class Objects”
  • 5. Anonymous Functions function() { // code goes here }
  • 6. Arrays data structure for ordered values var team = [‘ben’,‘jeff’,‘kam’]; team[0] // => ‘ben’
  • 7. Objects collections of “key/value” properties var person = {}; person.name = ‘will’; // Write var name = person.name; // Read
  • 11. What is jQuery Framework for using Javascript to interact with the browser • Simple DOM API: manipulate HTML / CSS on the page • Simple AJAX API: send and receive data from the server • Simple Event API: do stuff when the user does stuff • Thats it!
  • 12. What is a Framework? A library of utility functions Small Medium Large • Underscore.js • jQuery UI • YUI (Yahoo UI) • jQuery • MooTools • GWT (Google web toolkit) • Prototype.js • Dojo • EXT JS (commercial) there are LOTS of them for web development
  • 13. Why use jQuery • The DOM API is _nasty_! • Cross browser • Fast - Faster than raw DOM manipulation! *magic* • Lightweight (31kb) • Stable and trusted • Required for many other frameworks • EVERYBODY uses it
  • 14. Include jQuery <script src="/js/jquery.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/ jquery.min.js"></script> Try it out!
  • 15. jQuery Syntax or…how to follow the $ $(document).ready(function(){ // Your code here }); DOM Manipulation $("a").addClass("test");
  • 17. Selecting Elements Using CSS! $("#foo") // the [element] at id “foo” $(".bloop") // the [elements] with class “bloop” $("a.buzz") // the [links] with class ‘buzz’ $(".bloop:first") // specialty! The first bloop! => :hidden, :visible, :last, :checked, :empty, :odd...
  • 18. Important Methods .show() / .hide() / .toggle() $(".swap_text").toggle(); .addClass(".active") .removeClass(".active") .css(key, value) $("#my_box").css(‘backgroundColor’, ‘red’); $("#my_box").css({ ‘backgroundColor’ : ‘red’, ‘color’ : ‘#030’ });
  • 19. Important Methods .animate(properties, duration, callback) $(‘#my_box’).animate({ ‘backgroundColor’ : ‘red’, ‘marginTop‘ : ‘20px’, ‘color‘ : ‘#030’ }, 3000, justFinished); // execute the animation for 3 seconds // and when done, call: justFinished();
  • 20. Important Methods .html() / .val() / .attr(‘attribute’) $(‘#my_title’).html(); // returns the innerHTML $(‘#my_title’).html(“New Title!”); // sets the innerHTML $(‘input#email’).val(“please enter your email address...”); $(‘img’).attr(“src”, “placekitten.com/30/30”); as before: these methods can get or set...
  • 22. jQuery Events $(document).ready() // the DOM is loaded window.load() // all elements (including images) have loaded .change() .submit() .focus() .click .scroll() .hover() .keypress() ...And so many more!
  • 23. Events w/o jQuery no browser consistency EX: .addEventListener("click", function({}) ); // Firefox .attachEvent("onclick", function({}) ); // Internet Explorer
  • 25. Client Side Requests [XHR and AJAX]
  • 26. XMLHttpRequest Allows you to make a web request via client side javascript Invented by Microsoft for Internet Explorer, then ported to other browsers var request = new XMLHttpRequest(); // Create new request object request.open(“GET”, “path/file.ext”, false); // “open” the request request.send(null); // Make the request var text = request.responseText; // Check the response text
  • 27. BUZZZZWORD “XHR” • XMLHttpRequest • Misnomer => Not limited to XML data • By default, synchronous
  • 28. AJAX By default, XHR proceeds synchronously In other words, your code will hang until the request is complete What if you want your code to keep executing? => Use AJAX
  • 29. BUZZZZWORD “AJAX” • “Asynchronous Javascript and XML” • XHR done asynchronously • Provide a callback to execute when the request is complete • Changed the face of web development => page reloads no longer required to add new content to a page
  • 30. AJAX via DOM var request = new XMLHttpRequest(); // Create new request object request.open(“GET”, “path/file.ext”, true); // ‘True’ => AJAX request.send(null); // Make the request var text = request.responseText; // Will be null this time! request.onreadystatechange = function() { if (request.readyState == 4) { // Request is done. Can check responseText }
  • 31. AJAX via DOM var request = new XMLHttpRequest(); // Create new request object request.open(“GET”, “path/file.ext”, true); // ‘True’ => AJAX CONFUSING this time! request.send(null); // Make the request var text = request.responseText; // Will be null request.onreadystatechange = function() { if (request.readyState == 4) { // Request is done. Can check responseText }
  • 32. AJAX via jQuery $.ajax({   url: "test.html",   success: function(return_text){     $("#results").append(return_text);  } }); more next week...

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n