tags:

views:

220

answers:

3

I want to call this WS http://www.webservicex.net/country.asmx?op=GetCountries

What is the best possible way to do it using jQuery

+3  A: 

If you want to make Cross-Domain calls with jQuery you'll either have set-up a "proxy" file on your own server which fetches the remote contents and sends them to local jQuery or you need the webservice to support JSONP

duckyflip
Errr can't you just use ajax GET...http://docs.jquery.com/Ajax/jQuery.ajax#options
Fraser
Can you give an example with the above webservice i posted..it gives permission denied
Musa
+2  A: 

You could do this using the ajax method (either POST or GET). Here i use GET as all remote (not on the same domain) requests should be specified as GET. I also provide a callback method to show the result as an alert.

$.ajax({
   type: "GET",
   url: "http://www.webservicex.net/country.asmx",
   data: "op=GetCountries",
   success: function(msg){
     alert( "Result: " + msg );
   }
 });
Fraser
I did it exactly as you suggested and got the 'Permission Denied' error
Musa
Ah ok, use the jQuery.getJSON method instead like duckyflip stated: http://docs.jquery.com/Ajax/jQuery.getJSON
Fraser