Writing a function that returns a promise

The following is a sample code using which you can develop a good understanding on how to implement the promises in WT effectively. Follow these steps:

  1. Create a blank Windows Runtime app named IamPromise.
  2. Add an input element.
  3. Add a div element that displays the result for the URL.
  4. Add styling instructions to default.css to add some presentation in the app.
  5. Add a change handler for the input element.
  6. In the change handler, call xhr.
  7. Build and debug the app, and then enter a URL.
  8. Create a WT app in JS in VS2013.
  9. Add an input element.
  10. Within HTML, create an input element using the following code:
    <div> <input id="inputUrl" /> <!—the input id above is called input URL -- > </div> Add a DIV element that displays the ...

Get Mastering JavaScript Promises 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.