-
18 May 2012 8:06 PM #1
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.');
}
}
}]
}
});
-
19 May 2012 4:04 PM #2
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.
You can find how to create and use a store and proxy in the documentationCode:Ext.define("path", { extend: 'Ext.form.Panel', requires: [ 'Ext.data.JsonP' ], xtype: 'companyprofilepage', id: 'companyprofile', config: { scrollable: true, items: [{ xtype: 'list', store: 'weather' }] } });
http://docs.sencha.com/touch/2-0/#!/api/Ext.data.proxy.JsonP
There'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
-
21 May 2012 6:21 AM #3Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 435
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.


Reply With Quote