PDA

View Full Version : How to connect to a web service



kjd2984
21 Sep 2010, 1:36 AM
hi all,

I am a new newbie and wanted to connect to a web service. how do I do that. Any tips and examples?
Thanks.

evant
21 Sep 2010, 1:44 AM
The same way as you would with any other framework, just make an Ajax request and pass the appropriate parameters. There's examples under /examples/ajax

kjd2984
21 Sep 2010, 5:44 PM
thanks for the quick reply, but it seems that the /examples/ajax has been removed. could anyone pls post a sample ajax request for me to study. I am relatively new to this and would appreciate extra help. Thanks.

evant
21 Sep 2010, 7:21 PM
http://dev.sencha.com/deploy/touch/examples/ajax/

msubscribe
21 Sep 2010, 7:58 PM
hi Evant,

I would like to know how to fix the error in the example when I click on the button of the xmlhttprequest it shows Origin null is not allowed by Access-Control-Allow-Origin.

How can I allow cross domain access control allow origin? I'm accessing a web service outside the domain that loads it.

Thanks.

msubscribe
21 Sep 2010, 11:09 PM
I can now get the request on the web service using ext.util.jasonp.request. :) But I'm having a problem now on how I can read the response and assign it on a variable. Please help, thanks.


hi Evant,

I would like to know how to fix the error in the example when I click on the button of the xmlhttprequest it shows Origin null is not allowed by Access-Control-Allow-Origin.

How can I allow cross domain access control allow origin? I'm accessing a web service outside the domain that loads it.

Thanks.

mdrwxorg
22 Sep 2010, 3:16 AM
This is the way I do it:


var con = new Ext.data.Connection();
con.request({
url: 'update', // where to do the request
jsonData: jsonData, // << key value object with data to send
method: 'GET',
callback: function(opts, success, response) {
if (!success) {
Ext.MessageBox.alert("Error",
"Error retrieving data - try again");
return;
}
//use the answer of the request, which is contained in response.responseText
alert(response.responseText)
}

});