WebServices and Ajax.NET

Some developers asked me if it is possible to use WebServices (WebMethods) in Ajax.NET. Yes, of course, you can add the AjaxMethod attribute to the method. Ok, you do not want to change the WebService source code? My next release will include the possibility to add a simple JavaScript line in your HTML page to access your web services from the client side.

<html>
  <head>
    <script language="text/javascript" src="demoservice.asmx?AJAX"></script>
  </head>
  <body>
  <script language="text/javascript">
  
   var x = DemoService.ServerAdd(5, 6);
    alert(x.value);
  </script>
  </body>
</html>

That's all! You can use the web service like every Ajax.NET call you have done before, same syntax.

There is only one problem if you want to use web services on different domains. In most browsers it is not allowed to transport data between different domains.

8 Comments

  • Wallym said

    Excellent information. To be honest, I had wondered if your library had that capability. I am assuming you will be able to call into the web service asynchronously, is that correct?

    Wally

  • ROBINA said

    I really wonder if the webservice behaviour has some problem returning the real object.For the past one month I have been digging with that stuff and I got very much frustrated with behaviours.Now planning to switch to AJAX.I have been thinking that my code may be wrong.I want to ask michael schwarz if that really have some problem sometimes returning objects?

  • ROBINA said

    I wonder if really that webservice behaviour approach has some problem as michael schwarz stated?I have been digging withthose stuffs for past 1 month.But got frustrated as it couldnt return tha real object thinking that my code might be wrong and now switching to AJAX.Does it really have problem sometimes?

Comments have been disabled for this content.