locked
JSON ERROR

    Question

  • I am developing an app on YOGA asanas for windows8 desktop in javascript and html.In this i have prepared a file in JSON format with all the asanas information in it.I have incorporated the json file in data folder in solution explorer.I have included WINJS.XHR function in DATA.JS and also kept hide generate sample data function.when i run my app i have got an error named as JAVASCRIPT RUNTIME ERROR:INVALID CHARACTER for the line -var items=JSON.parse(xhr.responseText);    i am unable to remove this error.so i need  help to rectify the error.
    Friday, February 14, 2014 7:59 AM

Answers

  • Your JSON data is not vaild, try copy and paste it into the following page to see:

    http://jsonlint.com/

    Friday, February 14, 2014 8:13 AM
  • Hi chaitanya,

    Just give a guess, your xhr.responseText might be "undefined". 

    WinJS.xhr is a async method, you can only get data when the method is completed.

    WinJS.xhr(options).done(
            function completed(request) {
                // handle completed methods, for instance JSON convert.
            });

    Without seeing the code and the xhr.responseText, hardly to tell what's wrong, but hope this helps.

    --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.

    Monday, February 17, 2014 1:41 PM
    Moderator

All replies

  • Your JSON data is not vaild, try copy and paste it into the following page to see:

    http://jsonlint.com/

    Friday, February 14, 2014 8:13 AM
  • Hi chaitanya,

    Just give a guess, your xhr.responseText might be "undefined". 

    WinJS.xhr is a async method, you can only get data when the method is completed.

    WinJS.xhr(options).done(
            function completed(request) {
                // handle completed methods, for instance JSON convert.
            });

    Without seeing the code and the xhr.responseText, hardly to tell what's wrong, but hope this helps.

    --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.

    Monday, February 17, 2014 1:41 PM
    Moderator