views:

13343

answers:

6

I want to call a webservice from jquery. If there any idea?

+8  A: 

You can make an AJAX request like any other requests:

$.ajax( {
type:'Get',
url:'http://mysite.com/mywebservice',
success:function(data) {
 alert(data);
}

})
Marwan Aouida
Please correct the spelling of the onSuccess handler ... from sucess to success
drachenstern
A: 

Somewhat related to http://stackoverflow.com/questions/230401/how-to-use-jquery-to-call-an-asp-net-web-service/230605

shahkalpesh
i voted this up - cause it was exactly what i needed - and is related to the question being asked. Don't understand why it was voted down in the first place.
FiveTools
+2  A: 

http://docs.jquery.com/Ajax

Gromer
+3  A: 

The regular jQuery Ajax requests will not work cross-site, so if you want to query a remote RESTful web service, you'll probably have to make a proxy on your server and query that with a jQuery get request. See this site for an example.

If it's a SOAP web service, you may want to try the jqSOAPClient plugin.

Johnny G
+1  A: 

I blogged about how to consume a WCF service using jQuery:

http://yoavniran.wordpress.com/2009/08/02/creating-a-webservice-proxy-with-jquery/

The post shows how to create a service proxy straight up in javascript.

poeticGeek
A: 

Incase people have a problem like myself following Marwan Aouida's answer ... the code has a small typo. Instead of "success" it says "sucess" change the spelling and the code works fine.

Rob Cartlidge