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!
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!
Share Improve this question edited May 23, 2017 at 11:44 CommunityBot 11 silver badge asked May 10, 2013 at 12:26 ChrisChris 1,14617 silver badges29 bronze badges 2- An ASMX web service is just a SOAP web service. You can call it just like any other web service. What did you try? – Panagiotis Kanavos Commented May 10, 2013 at 12:30
- @ Panagiotis: What I am asking is actually if you can directly access the methods exposed in the ASMX service via javascript. If you read above, I had tried WCF first because that is possible there, but now im looking for other options. Thanks! – Chris Commented May 10, 2013 at 13:25
1 Answer
Reset to default 5As mentioned in ments, 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.