Results 1 to 4 of 4

Thread: JSON Error

  1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    11
    Vote Rating
    0
      0  

    Default JSON Error

    Hi,

    I contact you because I'm in a deadlock.
    I try to get data from a extern web service with "ScriptTag" but it does not work because the web service returns simple json format (No JSONP).

    Do you know if there is a another way to retrieve json using sencha ?

    PHP Code:
    var helloWorld = new Ext.Application({
         
        
    ParkingExt.regModel('Parking', {
            
    fields:[
                {
    name:'parkingName'},
                {
    name:'latitude'},
                {
    name:'longitude'},
                {
    name:'mapUrl'}
            ],
        }),
        
        
    launch: function() {
            
    this.tabs = new Ext.TabPanel({
                
    fullscreentrue,
                
    dockedItems: [{xtype:'toolbar'title:'JSON Recovery'}],
                
    tabBar: {
                    
    ui'light',
                    
    layout: {
                        
    pack'center'
                    
    }
                },
                
    items: [
                    {
    cls:'Page1'title:'Page1'html:'Page1'},
                       {
                        
    cls'list',
                        
    title'Page2',
                        
    xtype'list',
                        
    loadingText'Chargement',
                        
    itemTpl:'<div>{parkingName}</div>',
                        
    store: new Ext.data.Store({
                            
    autoLoad:true,
                            
    model'Parking',
                            
    proxy: {
                                
    type'scripttag',
                                    
    url :  'http://walker.hotcity.lu/hotcity-central-server/webresources/parking/json?format-version=1_0&client-type=iPhone',
                                
    reader: {
                                    
    type'json',
                                    
    root'remoteObject'
                                  
    },                         
                            }
                        }),
                        
                    },
                ],
                                
            });
        
        }
    }); 
    Code:
    warning : Resource interpreted as Script but transferred with MIME type application/json.
    error : Uncaught SyntaxError: Unexpected token :
    Thank You.

    Kevin.

  2. #2
    Touch Premium Member
    Join Date
    Sep 2008
    Location
    Orange County, CA, USA
    Posts
    186
    Vote Rating
    0
      0  

    Default Response?

    The Json Reader is choking on invalid Json. What's the response? You probably need to specify a different kind of reader (or no reader) or modify the returning json because...it's invalid json.

  3. #3
    Sencha User
    Join Date
    Apr 2011
    Posts
    11
    Vote Rating
    0
      0  

    Default

    I can use only two readers (ajax and scripttag). I tried with both, without reader but it still does not work.

    Now, I tried with another web service and I have only the warning :
    'warning : Resource interpreted as Script but transferred with MIME type application/json.'

    Is it possible to recover data from JSON ?
    Or, Sencha Touch only allows to retrieve data from JSON-P ?

  4. #4
    Sencha User realjax's Avatar
    Join Date
    Aug 2009
    Location
    Netherlands
    Posts
    412
    Vote Rating
    8
      0  

    Default

    It's valid JSON allright, it's just not wrapped in a callback function. Depending on how you setup your app (and maybe even depending on what OS it will run) you could try simple Ajax instead. The cross domain request might simply be allowed on the device (but never when run in a desktop browser such as Safari or Chrome though)

Similar Threads

  1. JSON error
    By Kurt001 in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 14 Mar 2011, 2:56 AM
  2. Error while trying to get json from url
    By Shiki in forum Sencha Touch 1.x: Discussion
    Replies: 8
    Last Post: 6 Dec 2010, 9:32 AM
  3. JSON response error
    By eertl in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 9 Jan 2009, 10:03 AM
  4. JSON error message
    By bhomass in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 24 Oct 2007, 5:42 PM
  5. JSON decode without JS Error on faulty JSON possible?
    By Wolfgang in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 23 Jul 2007, 11:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •