How to call WCF services from JavaScript jQuery and ASP.NET AJAX

First we have to create a webapplication and add to it Ajax enabled WCF service. Change default DoWork method to accept parameter

First add on the page input text control and two buttons.

First we will call this method with jQuery. So reference jQuery library and add this javascript function for calling WCF service

It’s very easy, you have to pass url with method, parameter (value from textbox) specify data type and callback function. Now you can run webapplication, put some text in input box and press button “jQuery call” Calling WCF service with Microsoft Ajax is much more easy. You do not to provide most of the properties like jQuery call.

After pressing button, you will have the same result. All source code can bi found below. I did not change web.config, so you can use default data generated by VisualStudio. ASPX page:

  C# code:



Comments

Social media

Search

Latest Tweets