嗨,我是sencha touch2的新手。我必须使用外部Web服务。我在控制台中编写了如下代码,它给出了这样的错误 Uncaught TypeError:无法调用未定义的方法'request'。有什么问题,请提供解决方案。谢谢
Ext.util.JSONP.request({
url: 'http://localhost/SLS.BRND.Services/Service1.asmx/Helloworld',
params: {
method: 'Helloworld',
format: 'json',
callback: 'callback'
},
success: function(response) {
alert('Working!')
console.log(response);
},
failure: function(response) {
alert('Not working!')
console.log(response);
}
});
答案 0 :(得分:5)
添加:
requires: ['Ext.data.JsonP'],
答案 1 :(得分:0)
Ext.data.JsonP.request({
url: 'http://localhost/SLS.BRND.Services/Service1.asmx/Helloworld',
params: {
method: 'Helloworld',
format: 'json',
callback: 'callback'
},
success: function(response) {
alert('Working!')
console.log(response);
},
failure: function(response) {
alert('Not working!')
console.log(response);
}
});
<强> DEMO 强>
希望这有帮助
答案 2 :(得分:0)
尝试 -
Ext.data.JsonP.request({
url: 'http://A-Valid-Domain/SLS.BRND.Services/Service1.asmx/Helloworld',
params: {
method: 'Helloworld',
format: 'json',
callback: 'callback'
},
success: function(response) {
alert('Working!')
console.log(response);
},
failure: function(response) {
alert('Not working!')
console.log(response);
}
});