Chaining Promises recursively
I'm working on a simple Windows 8 app in which I need to fetch a set of data from a web site. I am using WinJS.xhr() to retrieve this data, which returns a Promise. I then pass a callback into this Promise's .then() method, which supplies my callback with the returned value from the asynchronous call. The .then() method returns another Promise, giving it the value that my callback returns. The basic structure of such a query would be as follows: WinJS.xhr({ url: "http://www.example.com/" }).then( function callback( result_from_xhr ) { //do stuff return some_value; }).then( function