Customizing the Properties of the XmlHttpRequest Object

The WinJS.xhr() function is nothing more than a wrapper around the native browser XmlHttpRequest object. There are some cases in which you might need to use features of the underlying XmlHttpRequest object that are not exposed through the options of the WinJS.xhr() function. In these cases, you can take advantage of the WinJS.xhr() function’s customRequestInitializer option to customize the XmlHttpRequest object.

Imagine, for example, that you want to request and display the contents of a text file. Furthermore, you want to display download progress during the Ajax request.

The page in Listing 2.17 contains an HTML5 PROGRESS element (for displaying the download progress) and a DIV element ...

Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.