我是 sencha touch2 的新手,我想在 sencha touch2 中使用外部 Web 服务。我为此编写了代码,显示警报消息不起作用!在控制台中给出这样的错误 XMLHttpRequest cannot load http://localhost/SLS.BRND.Services/Service1.asmx/Helloworld?_dc=1336466078991&method=Helloworld&format=json。
Access-Control-Allow-Origin 不允许来源http://localhost:49692 。app/view/Blog.js?_dc=1336466047687:27响应状态:- 0
请帮我解决问题。谢谢
这是我的代码:-
Ext.define("GS.view.Blog", {
extend: 'Ext.navigation.View',
xtype: 'blog',
config: {
title: 'WebService',
scrollable: true,
items: [
{
xtype: 'button',
text: 'Press Me',
height: 40,
width: 200,
listeners: {
tap: function () {
// alert("Hi Welcome To Sencha");
Ext.Ajax.request({
method: 'GET',
url: 'http://localhost/SLS.BRND.Services/Service1.asmx/Helloworld',
params: { method: 'Helloworld', format: 'json' },
success: function (response, request) {
alert('Working!')
alert(response.responseText)
console.log('Response:-' + response.responseText)
},
failure: function (response, request) {
alert('Not working!')
console.log('Response Status:- ' + response.status)
}
});
}
}
}
]
}
});