JSONP请求不工作
嗨,我是Sencha的新手,我正在尝试将json请求数据设置为filedset。但它不起作用。请帮助我,我找不到错误 这是我的json请求数据:JSONP请求不工作,json,request,sencha-touch,jsonp,Json,Request,Sencha Touch,Jsonp,嗨,我是Sencha的新手,我正在尝试将json请求数据设置为filedset。但它不起作用。请帮助我,我找不到错误 这是我的json请求数据: {"response":{"electric_current":103.7506250769956,"electric_power":120.62350489414762}} 这就是代码 Ext.define('AIOS_vis.view.Main', { extend: 'Ext.tab.Panel', xtype: 'main'
{"response":{"electric_current":103.7506250769956,"electric_power":120.62350489414762}}
这就是代码
Ext.define('AIOS_vis.view.Main', {
extend: 'Ext.tab.Panel',
xtype: 'main',
requires: [
'Ext.TitleBar'
],
config: {
listeners: {
activate: function() {
alert('gr');
Ext.data.JsonP.request({
url: 'http://localhost:8080/mock/GetCtPwer.php',
method: 'POST'
callbackkey: 'callback',
params: {
tap_id: 1
},
scope: this, /// fix handler scope
callback: function (response, value, request) {
var wattComponent = Ext.getCmp('watt');
wattComponent.setValue(value.response.electric_power);
var ampereComponent = Ext.getCmp('ampere');
ampereComponent.setValue(value.response.electric_current);
},
failure: function (response, request) {
Ext.Msg.alert(response);
}
});
}
},
tabBarPosition: 'bottom',
items: [
{
title: 'Home',
iconCls: 'home',
styleHtmlContent: true,
scrollable: true,
items: [
{
docked: 'top',
xtype: 'titlebar',
title: 'Visual',
},
{
xtype: 'fieldset',
instructions: 'Last Update: 2014/02/06:12:45:23',
items: [
{
xtype: 'button',
text : 'current',
height: '40px',
},
{
xtype: 'textfield',
id: 'watt',
label: 'Wattage (W):',
text: '1890.9W'
}, {
xtype: 'textfield',
id: 'ampere',
label: 'Amperage (A):',
text: '18.91A'
}]
},
{
xtype :'titlebar',
style: 'background:#484848',
title : 'power</br>123.4Wh',
height: '100px'
}
]}
]
},
});
Ext.define('AIOS_vis.view.Main'{
扩展:“Ext.tab.Panel”,
xtype:'main',
要求:[
“外部标题栏”
],
配置:{
听众:{
激活:函数(){
警报(“gr”);
Ext.data.JsonP.request({
网址:'http://localhost:8080/mock/GetCtPwer.php',
方法:“发布”
callbackkey:'callback',
参数:{
水龙头编号:1
},
作用域:此,///修复处理程序作用域
回调:函数(响应、值、请求){
var-wattComponent=Ext.getCmp('watt');
瓦特组件设定值(值、响应、电功率);
var安培分量=Ext.getCmp(‘安培’);
安培组件.设定值(值.响应.电流);
},
故障:功能(响应、请求){
外部消息警报(响应);
}
});
}
},
tabBarPosition:'底部',
项目:[
{
标题:"家",,
iconCls:“家”,
styleHtmlContent:对,
可滚动:对,
项目:[
{
停靠:“顶部”,
xtype:'标题栏',
标题:'视觉',
},
{
xtype:“字段集”,
说明:“上次更新:2014/02/06:12:45:23”,
项目:[
{
xtype:'按钮',
文本:“当前”,
高度:'40px',
},
{
xtype:'textfield',
id:'瓦特',
标签:“瓦数(W):”,
文字:“1890.9W”
}, {
xtype:'textfield',
id:'安培',
标签:“电流(A):”,
文字:“18.91A”
}]
},
{
xtype:“标题栏”,
风格:“背景:#4848”,
标题:“功率123.4Wh”,
高度:“100px”
}
]}
]
},
});
将您的Web服务url更改为(例如)
并确保您的Webseries正在响应:
parseResponse({“响应”:{“电流”:103.7506250769956,“电力”:120.62350489414762})
您可以将“parseResponse”更改为您想要的任何内容