Chris
Chris

Reputation: 1146

Can you consume ASMX webservices from javascript?

Can you consume ASMX webservices directly from Javascript / JQuery? I am having issues hosting/developing a good solution with WCF so I wanted to see what other options are out there as far as connecting my already-developed front end to some backend C# code. For reference there is also a question out there regarding my WCF issue here: Completing the WCF implementation picture

Update: I would also accept as an answer, an alternative solution for me to access c# code. I already have my frontend developed, so I just want to avoid having to replace my GUI elements with ASP.NET runat-server controls! Thanks!

Upvotes: 3

Views: 5830

Answers (1)

Kamyar
Kamyar

Reputation: 18797

As mentioned in comments, ASMX web services are standard SOAP services. And yes, you can call its methods like below:

$.ajax({
  type: "POST",
  contentType: "application/json; charset=utf-8",
  url: "WebService.asmx/WebMethodName",
  data: "{}",
  dataType: "json"
});

You can read more on it in this great tutorial.

Upvotes: 5

Related Questions