Book Image

Mastering JavaScript Promises

Book Image

Mastering JavaScript Promises

Overview of this book

Table of Contents (16 chapters)
Mastering JavaScript Promises
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 result for the URL.
    
    <div id="ResultDiv">Result</div>
    <!—the div id named here as ResultDiv -- >
    
    Add the styling instructions to "default.css".
    
    input {
      // add your style statements here
    }

Adding a change...