1. #1
    Sencha User
    Join Date
    May 2012
    Location
    Bangalore
    Posts
    73
    Vote Rating
    0
    Rameshlamani is on a distinguished road

      0  

    Default Expected ':' in sencha touch2

    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
    9
    pepperseb is on a distinguished road

      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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,624
    Vote Rating
    435
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      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 @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

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

Tags for this Thread