How To Call Webservice In Javascript For Firefox 3.0
I have a problem with calling .Net web services with a Firefox client. A simple example will be enough for me. Server side code is like this: [WebService(Namespace = 'http://tempur
Solution 1:
If you are planning to consume your web service in NET, I would suggests using ScriptService, The client API is easier and should be working on most browsers, see below for a sample:
namespaceXXX.Services
{
[System.Web.Script.Services.ScriptService()]
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
publicclassService1 : System.Web.Services.WebService
{
[WebMethod] publicstringHelloWorld()
{
return"Hello World";
}
[WebMethod] publicstringGreet(string name)
{
return"Hello " + name;
}
}
}
Client side html code:
Hello World Denemesi
<button onclick="test1()">print</button>
Client side .js code:
<script>functiontest1(){
XXX.Services.HelloWorld(function(result){
alert(result);//do something with the result
});
XXX.Services.Greet("John Cane",function(result){
alert(result);
});
}
</script>
Solution 2:
You could use the jQuery ajax calls, they make calling web services easy. See here: http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/
Post a Comment for "How To Call Webservice In Javascript For Firefox 3.0"