Example 781 Monitoring the progress of an uploaded Ole function

Example 781 monitoring the progress of an uploaded

This preview shows page 94 - 97 out of 148 pages.

Example 7.8.1: Monitoring the progress of an uploaded Ole. function uploadProgressHandler ( event ) { if ( event . lengthComputable ) { console . log ( event . loaded + " bytes uploaded out of " + event . total + " bytes total. " ) ; } } var file = document . getElementById ( " file_widget " ). files [ 0 ] ; var xhr = new XMLHttpRequest () ; xhr . upload . addEventListener ( " progress " , uploadProgressHandler ) ; xhr . open ( " POST " , " " ) ; xhr . setRequestHeader ( " Content-Type " , file . type ) ; xhr . send ( file ) ; PARTICIPATION ACTIVITY 7.8.9: Uploading Oles using XMLHttpRequest. This activity failed to load. Please try refreshing the page. If that fails, you might also try clearing your browser's cache. If an issue persists, send feedback to zyBooks support ©zyBooks 12/15/19 01:37 508993 ABRAHAM PARKER CUNYCSCI355TeitelmanFall2019 ©zyBooks 12/15/19 01:37 508993 ABRAHAM PARKER CUNYCSCI355TeitelmanFall2019 ... 94 of 148 12/15/19, 1:38 AM
Image of page 94
Exploring further: XMLHttpRequest from MDN 1) xhr.addEventListener("progress", handler) tracks the status of a request to the server. 2) The XMLHttpRequest object can use a GET or POST request to upload Oles to a server. 3) When uploading Oles to a server, the Content-Type header indicates the type of Ole being uploaded. 4) The XMLHttpRequest object's load handler takes an event object as an argument. 5) The XMLHttpRequest object's progress handler takes an event object as an argument. True False True False True False True False True False ©zyBooks 12/15/19 01:37 508993 ABRAHAM PARKER CUNYCSCI355TeitelmanFall2019 ©zyBooks 12/15/19 01:37 508993 ABRAHAM PARKER CUNYCSCI355TeitelmanFall2019 ... 95 of 148 12/15/19, 1:38 AM
Image of page 95
HTTP access control (CORS) from MDN 7.9 Using third-party web APIs (JavaScript) Introduction Many organizations have created public web APIs that provide access to the organization's data or the user's data that is stored by the organization. Ex: The Twitter API provides applications the ability to post or access a user's tweets, and the Instagram API allows applications access to photos shared on Instagram. ProgrammableWeb lists details on thousands of public web APIs, many of which are free to use. A third-party web API is a public web API used by a web application to access data provided by a third party. "Third-party" refers to a person or organization that is neither the web application using the API nor the user using the web application, which are the "Orst" and "second" parties. Websites rely on third-party web APIs to integrate with social media, obtain maps and weather data, or access collections of data. To use a third-party web API, a developer usually registers with the third party to obtain an API key . Third parties require API keys for several reasons: The API key identiOes who or what application is using the web API.
Image of page 96
Image of page 97

You've reached the end of your free preview.

Want to read all 148 pages?

  • Fall '19
  • Document Object Model, HTML element, ABRAHAM PARKER

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes