Creating the Data Source

The web service data source uses the WinJS.xhr() method to make the Ajax calls to the remote web service. For example, the getCount() method looks like this:

getCount: function () {    var that = this;    return new WinJS.Promise(function (complete, error) {        var options = {            url: that._url + "/getCount"        };        return WinJS.xhr(options).then(function (xhr) {            var count = JSON.parse(xhr.response);            complete(count);        },        function (xhr) {            console.log("Could not call getCount()");        });    });}

The getCount() method invokes a remote web service action named getCount() by performing an HTTP GET request.

Here’s another of ...

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.