问题
I am very new to sencha touch application, i've been tasked to get the json data from a cross domain and data looks like below
{ "data": { "error": [ {"msg": "Free API has moved to
free.worldweatheronline.com\/feed\/weather.ashx url.
Please make changes at your end. Please contact support team at
info@worldweatheronline.com for any other issues." } ] }}
How to trigger a callback function for this json data,i can able to request but the callback function is not triggering.Can anyone help me out in this?thanks in advance
回答1:
Are you using JSONP request this way?
Ext.data.JsonP.request({
url: 'YOUR JSONP URL',
callbackName: 'someCallbackFunctionName',
success: function(data) {
console.log(data);
}
});
And you have to wrap the data you are returning in a function whose name you are passing as "callbackName" config. So, the data you will send from server must look like this:
someCallbackFunctionName({ "data": { "error": [ {"msg": "Free API has moved to
free.worldweatheronline.com\/feed\/weather.ashx url.
Please make changes at your end. Please contact support team at
info@worldweatheronline.com for any other issues." } ] }})
Do check the jsonp details in Sencha API.
来源:https://stackoverflow.com/questions/9596166/how-to-access-jsonp-data-using-ext-util-jsonp-request