Online Since 1995. Yep, that long.

Adventures in Windows 8: Sending an HTTP POST Request with WinJS.xhr

Tags: Adventures in Windows 8, WinJS, HTTP, xhr

One of the many things I learned last week was how to use the WinJS.xhr object to send an HTTP POST request to a remote server.

In case you’re wondering, this is how it’s done.

        var targetUri = "http://sampleUri/form.aspx";
        var formParams = "sampleField=" + escape(sampleFieldContent);
            type: "post",
            url: targetUri,
            headers: { "Content-type": "application/x-www-form-urlencoded" },
            data: formParams
        }).then(function (xhr) {

        // This code executes when the xhr response is complete.
Add a Comment