Forum /
Sencha Touch 2.x Forums /
Sencha Touch 2.x: Discussion /
How can I access webservice using sencha touch2?
How can I access webservice using sencha touch2?
I have created "Hello World" webservice, I am trying to access webservice using Sencha touch2 and SDK. but it didn't show any output as well as error. I have used below code in App.js file.
Ext.Ajax.request({
url: 'http://localhost:3661/Service1.asmx?op=HelloWorld ',
success: function(response) {
console.log("Success" + msg)
},
failure: function (msg) {
console.log("Failure" + msg)
}
});
when I tried to browse index.html page it didn't show me the output. can someone please guide me?
Last edited by Tejendra; 30 Apr 2012 at 1:12 AM .
Reason: Spell correction
Sencha - Senior Forum Manager
Any errors like cross-origin blocking?
Hi,
Thanks for looking into this. No Error like cross-origin blocking. I have writen new code to call WCF service in app.js file as below :
Ext.Ajax.request({
url: 'http://localhost:2908/Service1.svc/',
method: 'get',
params: {value: 10},
callback: function(response, opts) {
console.log(response.responseText);
},
jsonData: { "Alert": {} },
headers: { 'Content-Type text/xml': 'application/json;charset=utf-8' },
success: function (response, opts) {
alert(response.responseText);
alert("Hi")
}
})
Now when I ran index.html file in crome browser it call's the service but does not return any output. when I press F12 it shows me below error :
" XMLHttpRequest cannot load http://localhost:2908/Service1.svc/?...18856&value=10 . Origin http://localhost is not allowed by Access-Control-Allow-Origin.
app.js:6undefined"
Is it beacause of I am using ajax request to call WCF service? Do I need to use JSONP ?
I have tried to call wcf service using Jquery but looks like syntaxes of jquery not supported in app.js file.. can you please guide me?
Thanks,
Tejendra
Sencha - Senior Forum Manager
So you are getting a cross-origin block error. YOu need to do one of two things, enable CORS on the server or use JsonP
Sencha is used by over two million developers. Join the community, wherever you’d like that community to be
or Join Us