locked
Data retrieval by the WinJS.xhr object with JSON Api

    Question

  • Hello people,

    I need help with my first little Windows 8 app project! I want to make a kind of news app that retrieves the feed my own website and this last updated every time.

    I did try this by Win.JS.xhr object with JSON Api I have subsequently installed in WordPress, but no data is retrieved.

    Here is the Code:

        WinJS.xhr({ url: 'http://appdata.stefanmahr.com/json' }).done(function (res) {
            var content = JSON.parse(res.responseText);
        });

    If you need more Informations you can send me a Skype-request: stemah1

    I hope you can help me!

    Sincerely yours
    Stefan Mahr

    Saturday, October 19, 2013 5:48 PM

All replies

  • Hi Stefan,

    I tried your code and it seems works fine, see the screenshot below, is there anything wrong with my code?

    Or do you mean you cannot get the last updated data? You could use If-Modified-Since to fouce refresh, more information can be found here  How to ensure that WinJS.xhr resends requests

    Best Regards,

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Sunday, October 20, 2013 2:39 AM
    Moderator
  • Hey James,

    Thanks for your answer! I tryed it again and it doesn't work. I didn't know what the Problem is but I works Yesterday only 1 time!

    Best Regards,

    Stefan


    • Edited by Stefan Mahr Sunday, October 20, 2013 8:06 AM
    Sunday, October 20, 2013 8:03 AM
  • Hi Stefan,

    Could you validate if you can access your JSON from web browser?

    I don't have any clue now. You fetched the data yesterday, and succeed once, means the code from your project should be OK. Maybe you could try to find if this is your firewall issue or the server side issue.

    Following statement allows you collect the error message, try to find if there is some error information provided by your app.

    WinJS.xhr(options).done(
            function completed(request) {
                // handle completed download.
            }, 
            function error(request) {
                // handle error conditions.
            }, 
            function progress(request) {
                // report on progress of download.
            });
    

    Best Regards,

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Sunday, October 20, 2013 9:24 AM
    Moderator
  • Hey James!

    Yes I can access the JSON from my webbrowser without any Problems!

    I will now look if my Firewall is the Problem.

    Best Regards,

    Stefan

    Sunday, October 20, 2013 7:03 PM