PDA

View Full Version : Problem using JsonP Store



bevara.siva
23 May 2014, 2:39 AM
Hi,

We are using Ext JS 4.2.2.

We need to load the data from a service which is residing ina different domain. So we are using JsonP Store to load the data from the service. We are facing the following issue while trying to load the data in the store.

Unable to load data using the supplied configuration.
Open in Browser: <Service URL>

When I use the service URL in a browser it is properly loading the data in the browser.
Following is store configuration:



Ext.define('ViewSample.store.XMLServiceStore', {
extend: 'Ext.data.Store',


requires: [
'ViewSample.model.StackedModel',
'Ext.data.proxy.JsonP',
'Ext.data.reader.Json'
],


constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
model: 'ViewSample.model.StackedModel',
storeId: 'XMLServiceStore',
proxy: {
type: 'jsonp',
url: '<Service URL>',
reader: {
type: 'json',
root: 'GetEmployeesResult'
}
}
}, cfg)]);
}
});


Please help!!!

Regards,
SivaPrasad.B

scottmartin
23 May 2014, 6:53 AM
It is having problems reading the response JSON. Make sure it is formatted correctly and that you root, etc is correct.

What does the json look like?

bevara.siva
28 May 2014, 11:03 PM
Thank you for the response.
I believe its not the issue with JSON. Same Json is working with the JsonStore but not working with JsonPstore.

Following is the Json we are returning.


{"GetResult":
[{"Account_ID":"SMITH","X_Price":15000,"Y_Price":20000,"Z_Price":-10000,"A_Price":25000,"Type":"SIE","Total":50000},{"Account_ID":"SMITH","X_Price":10000,"Y_Price":15000,"Z_Price":5000,"A_Price":20000,"Type":"VODA","Total":50000},{"Account_ID":"SMITH","X_Price":0,"Y_Price":5000,"Z_Price":0,"A_Price":10000,"Type":"MBI","Total":15000},{"Account_ID":"SMITH","X_Price":25000,"Y_Price":50000,"Z_Price":20000,"A_Price":30000,"Type":"UDR","Total":195000},
{"Account_ID":"SMITH","X_Price":20000,"Y_Price":-25000,"Z_Price":-15000,"A_Price":50000,"Type":"RUE","Total":30000}]}


Please help!!!

Regards,
SivaPrasad.B

skirtle
29 May 2014, 12:27 AM
JSON and JSON-P are not the same thing.

For cross-domain requests I suggest you thoroughly research both JSON-P and CORS.