• Home /
  • Blog /
  • How to call WCF services from JavaScript jQuery and ASP.NET AJAX

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:

Yaplex - Freelance developer - white logo on black background

Yaplex ® is a custom software development company located in Mississauga, Ontario. Yaplex was founded in 2013 and provides website development, mobile development, and custom .NET software development services.

Contact Information

Mississauga, ON, Canada
Phone: +1 647 328 3809
Email: hello@yaplex.com