问题描述
我对sencha touch应用程序非常陌生,我受命从跨域获取json数据,数据如下所示
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
[email protected] for any other issues." } ] }}
如何触发此json数据的回调函数,我可以请求,但回调函数未触发.有人可以帮我吗?谢谢
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
推荐答案
您是否以这种方式使用JSONP请求?
Are you using JSONP request this way?
Ext.data.JsonP.request({
url: 'YOUR JSONP URL',
callbackName: 'someCallbackFunctionName',
success: function(data) {
console.log(data);
}
});
并且您必须将要返回的数据包装在一个函数中,该函数的名称将作为"callbackName"配置传递.因此,您将从服务器发送的数据必须如下所示:
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
[email protected] for any other issues." } ] }})
请检查 jsonp详细信息在Sencha API中.
Do check the jsonp details in Sencha API.
这篇关于如何使用Ext.util.JSONP.request访问jsonp数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!