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:
- Create a blank Windows Runtime app named
IamPromise
. - Add an
input
element. - Add a
div
element that displays the result for the URL. - Add styling instructions to
default.css
to add some presentation in the app. - Add a change handler for the
input
element. - In the change handler, call
xhr
. - Build and debug the app, and then enter a URL.
- Create a WT app in JS in VS2013.
- Add an
input
element. - 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.