locked
WinJS JSON Parsing Problem

    Question

  • I have been following a tutorial called "First Taste of WinJS" (here: http://slickthought.net/post/2012/08/16/Windows-8-and-HTML-Part-5-Fetch-Data-with-WinJS.aspx)

    and we are given this code snippet:

    WinJS.xhr({ url: "http://search.twitter.com/search.json?q=%23windows8&rpp=100" }).then(

    function (response) { var json = JSON.parse(response.responseText); var list = new WinJS.Binding.List(json.results); var title = WinJS.Utilities.query('.pagetitle')[0]; title.textContent = list.length; }, function (error) { console.log(error); }, function (progress) { } );

    The problem I am having is, when I edit the url to a YouTube feed (http://gdata.youtube.com/feeds/api/users/razethew0rld/uploads?&v=2&max-results=50&alt=jsonc) for example.

    The list length returns 0. Is there something I am over-looking?

    Thanks for reading my question, I would appreciate any help.

    Sunday, March 31, 2013 5:18 PM

Answers

  • Hi,

    Please refer to the code as follow:

     function CallData() {
            var person = { 'Name': 'Name'};
            WinJS.xhr({
                type: "POST",
                url: "http://www.xxx.com/WebService.asmx/method",
                headers: { "Content-type": "application/json" },
                data: JSON.stringify(person)
            }).then(function complete(request) {
                var resdata = request.responseText;
            }, function error(er) {
                var err = er.statusText;
            });
        }


    Roy
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by ViralBeeb Tuesday, April 2, 2013 9:11 AM
    Monday, April 1, 2013 3:34 AM