Overview Ajax Xmlhttprequest and Jquery

Overview Ajax Xmlhttprequest and Jquery

CS50 Ajax Overview Key Terms Back in the 1990s, any time a website was slightly updated with new information, the • Ajax entire webpage had to be refreshed and reloaded. Today, thanks to some techniques • JSON collectively known as Ajax, we can incrementally update parts of web pages without • asynchronous interrupting a user’s experience. You’ve probably seen this on Google when it gives programming you search suggestions as you type. Any time you see a portion of a web page update • XMLHttpRequest without the entire web page refreshing, that’s Ajax at work. Ajax w/o Ajax w/ Ajax Ajax, short for asynchronous JavaScript and XML, is an ap- proach to using existing technologies to make dynamic HTTP web browser web browser requests. Web applications usually work like this: a request is made from a browser to get information from a server, the server sends the appropriate information, and the browser updates the user’s page. However, with Ajax, there is an inter- mediary between the browser and the server known as the Ajax engine; the visual presentation of a website (HTML/CSS) is separated from the handling of HTTP requests. By using an Ajax engine (written in JavaScript) to handle HTTP requests, JS call the actual HTML and CSS page displayed on the browser is HTML/ upheld while the request is being made. After the information CSS from the request has reached the browser, the Ajax engine Ajax engine can directly update just a portion of the page’s HTML or CSS, preventing the entire page from reloading. Because the server is no longer needs to send entire HTML/ CSS data, Ajax uses simple notations to send small packets of information. XML, or Extended Markup Language, is a nota- tion used to send information. However, most programmers today use JSON, or JavaScript Object Notation, instead be- HTML/ JSON/ cause it is native to JavaScript. HTTP HTTP CSS HTML request request data data All of these technologies work together to enable asynchro- nous programming. Synchronous programming is when you have to wait for previous parts of your program to finish run- ning before moving onto another task. However, in web pro- gramming, the web application has to be listening for many possible events at once and then act accordingly. Asynchro- nous programming allows programs to handle multiple tasks at once. Using asynchronous programming with JavaScript means web applications can wait and respond to any number server server of events, reducing application response time and improving user experience. XMLHttpRequest and jQuery The programming techniques that make up Ajax are wrapped up in a native Javascript object known as the XMLHttpRequest (XHR) object. This object contains the functions to control the Ajax engine and perform asynchronous HTTP requests. The XHR object allows functions to be dependent upon what state a request is in, enabling seamless experiences for users of web applications. Many programmers use XHR indirectly through jQuery because the syntax is more convenient. Thanks to programmers before us, all you have to do to take ad- vantage of Ajax in your projects is read through the jQuery and XHR object documentation. © 2018 This is CS50..

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    1 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us