-
14 Aug 2012 8:47 AM #1
How do I get the values from a Sencha JsonP response?
How do I get the values from a Sencha JsonP response?
I am new to Sencha touch am having trouble getting the values from a Sencha jsonp request. This is for a mobile application's login screen.
Here is my controller.
Ext.define('MyApp.controller.Main', {
extend: 'Ext.app.Controller',
refs: [
{
ref: 'loginForm',
selector: '#loginForm'
}
],
init: function() {
this.control({
'button[action=submitLogin]': {
tap: 'submitLoginForm'
}
});},
submitLoginForm: function() {
var form = this.getLoginForm();
Ext.define('Login', {
extend: 'Ext.data.Model',
fields: ['id', 'username', 'email']
})
var store = Ext.create('Ext.data.Store', {
model: 'Login',
proxy: {
type: 'jsonp',
url: 'http://some-url/auth.php',
appendId: true,
limitParam: false,
enablePagingParams: false,
startParam: false,
},
reader: {
type: 'json',
rootProperty: 'user'
}
})
},
});
Once the submit button is tapped everything works fine but I'm not sure how to get the values in the json string. Below is the json.
Ext.data.JsonP.callback1({"user":[{"id":"1","username":"me","email":"some@thing.com"}]});
Any help would be appreciated.
-
15 Aug 2012 2:17 PM #2
The values will be added to the store. You can then use:
Scott.Code:store.each(function(record) { record.get('field'); }):


Reply With Quote