Results 1 to 3 of 3

Thread: Expected ':' in sencha touch2

  1. #1
    Sencha User
    Join Date
    May 2012
    Location
    Bangalore
    Posts
    95
    Vote Rating
    1
      0  

    Default Expected ':' in sencha touch2

    Hi i am new to sencha touch2. i called web service as below but it is giving error like expected ':' please tel me what is d pbm. how to fix it.

    here is my code:

    Ext.define("path", {
    extend: 'Ext.form.Panel',
    requires: [
    'Ext.data.JsonP'
    ],
    xtype: 'companyprofilepage',
    id: 'companyprofile',
    config: { scrollable: true,
    items: [{
    xtype: 'list',
    Ext.data.JsonP.request({ //hi Here i am getting error like expected ':'
    url: 'http://free.worldweatheronline.com/feed/weather.ashx',
    callbackKey: 'callback',
    params: {
    key: '23f6a0ab24185952101705',
    q: '94301', // Palo Alto
    format: 'json',
    num_of_days: 5
    },
    callback: function (success, request) {
    var weather = request.data.weather;
    if (weather) {
    panel.updateHtml(tpl.applyTemplate(weather));
    }
    else {
    alert('There was an error retrieving the weather.');
    }
    }
    }]
    }
    });

  2. #2
    Sencha User
    Join Date
    Apr 2012
    Posts
    103
    Vote Rating
    10
      0  

    Default

    You have to share the logic: You should use a store with a proxy to call the webservice and only use the view to display the information.

    Code:
    Ext.define("path", {
    extend: 'Ext.form.Panel',
    requires: [
    'Ext.data.JsonP'
    ],
    xtype: 'companyprofilepage',
    id: 'companyprofile',
    config: { scrollable: true,
    items: [{
    xtype: 'list',
    store: 'weather'
    
    }]
    }
    });
    You can find how to create and use a store and proxy in the documentation
    http://docs.sencha.com/touch/2-0/#!/api/Ext.data.proxy.JsonP

    T
    here's also a great example, which is similar to what you want, in the Kitchen Sink example, Data > JSONP
    http://docs.sencha.com/touch/2-0/#!/...e/kitchen-sink

  3. #3
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    Your response probably isn't valid JSONP. You can check the response with http://www.jsonplint.com/ but most likely you didn't surround the JSON with the callback function.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

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