1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    25
    Vote Rating
    0
    Answers
    3
    xiii29 is on a distinguished road

      0  

    Default Answered: JSON Error on phone not on desktop

    Answered: JSON Error on phone not on desktop


    Hi,


    After packaging my app (sencha command build), I've upload my app on a
    server to test the result.
    Everything is ok on my desktop on google chrome but not working on the
    navigator of my phone (androïd 2.3.6).


    On the phone's navigator, I've got this message :
    "[WARN][Ext.data.reader.Reader#process] Unable to parse the JSON
    returned by the server: Error: You're trying to decode an invalid JSON
    [...]"


    I've set my JSON on JSONLint : valid.


    I've check the result in the network console : 200 - application/json -
    UTF8.


    Here is the url on the JSON :
    http://nantesparcours.lafamillebn.ne...angements/zone


    As it may come from the store code :
    Code:
    Ext.define("MyApp.store.Changes", {
         extend: "Ext.data.Store",
         config: {
               model: "MyApp.model.Change",
               proxy: {
                    type:'ajax',
                    url:'http://nantesparcours.lafamillebn.net/api/changements/zone',
                    reader: {
                       type:'json', 
                       rootProperty:'changement',
                    }// reader
               }, // proxy
               sorters: [ { property: 'horodatage', direction: 'DESC' } ],
         }, // config
    }); // fin

    Thanks for any help. Hope to give all info ...

  2. For info, I've also update to sencha touch 2.1 but ajax / json i've still have to trouble. Working fine with JSONP.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,545
    Vote Rating
    873
    Answers
    3566
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Are you loading your app on the nantesparcours.lafamillebn.net domain or from another domain?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Nov 2012
    Posts
    25
    Vote Rating
    0
    Answers
    3
    xiii29 is on a distinguished road

      0  

    Default


    Hi,

    I'm loading from another subdomain. For a while i've some message of Allow Acces but I'm managed by changing the configuration of my web server. And it's working now.

    On my phone javascript console, I can see the content of my data just after the error message ...

    I'm wondering if it's not a encondig trouble ...

  5. #4
    Sencha User
    Join Date
    Feb 2011
    Location
    Düsseldorf, Germany
    Posts
    587
    Vote Rating
    32
    Answers
    34
    Kurt001 has a spectacular aura about Kurt001 has a spectacular aura about

      0  

    Default


    I remember that some old iPhone versions did not support JSON. You might want to test the following:
    Code:
    if(!window.JSON) alert("No - this really does not support JSON");
    Just to make sure its not because of the phone.

  6. #5
    Sencha User
    Join Date
    Nov 2012
    Posts
    25
    Vote Rating
    0
    Answers
    3
    xiii29 is on a distinguished road

      0  

    Default


    One of my store load a local json files and it's working fine ...

  7. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,545
    Vote Rating
    873
    Answers
    3566
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    What I was getting at is the cross origin security which you just have to send a header to support CORS.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  8. #7
    Sencha User
    Join Date
    Nov 2012
    Posts
    25
    Vote Rating
    0
    Answers
    3
    xiii29 is on a distinguished road

      0  

    Default


    Hi,

    I'm sorry I'm not to understand your last message ... (my english is as good as ... my sencha .

    To resolved the cross error, i've changed my .htaccess by adding to lines that allow the needed request.

    For now, i've still the error on Androîd while it's working fine on desktop ...

  9. #8
    Sencha User
    Join Date
    Nov 2012
    Posts
    25
    Vote Rating
    0
    Answers
    3
    xiii29 is on a distinguished road

      0  

    Default


    I've set up a JSON Viewer App on my phone and load my url ==> no error ... (https://play.google.com/store/apps/d...=search_result)

  10. #9
    Sencha User
    Join Date
    Nov 2012
    Posts
    25
    Vote Rating
    0
    Answers
    3
    xiii29 is on a distinguished road

      0  

    Default


    Hi,
    On order to move forward, I've develop a very small app that's just load the distant file. On my web site, I've change the return, in order to remove data. The service return only to root name :

    Code:
    {"c":""}
    I've put the new app on my server and the problem persist but I've found that the javascript console of my app write
    Code:
    [Warn][Ext.data.reader.Reader#process] Unable to parse [...] an invalid JSON STring: {"c:"" }{"c":""}
    From what I see in the code, there is no reason for my string to be recopied in the error message ...

  11. #10
    Sencha User
    Join Date
    Nov 2012
    Posts
    25
    Vote Rating
    0
    Answers
    3
    xiii29 is on a distinguished road

      0  

    Default


    Hi ...
    I've made lot of trace directly on the sencha src to see what happen. As far as I am, the text is "doubled" directly in the response in src/proxy/Server :
    Code:
        221     processResponse: function(success, operation, request, response, callback, scope) {
        222         console.log("Servers.js : processResponse");
        223         console.log(request);
        224         console.log(response.responseText);
        225         console.log("Servers.js : processResponse apres log");
    When I look on my phone (Adnroïd : 2.3.6) the response.responseText : {"c":"""}{"c":"""}
    the same on Google Chrome Desktop :{"c":"""}

    For info : i made a test on a old Iphone : {"c":""} ...

    UPDATE : I've made a test on Androïd 4.1.2 --> look's fine ...

Thread Participants: 2

Tags for this Thread