R – consume a asp.net web service that returns json from an stand alone html page


I've developed a web service in asp.net and am able to test it from an in-project aspx page and can readily display the information that was returned in JSON format.

I now need to consume the web service from a stand-alone html page.

Does someone have experience with this? I'm puzzled by the part that would replace this

<asp:ScriptManager ID="ScriptManager" runat="server">
        <asp:ServiceReference Path="~\MyService.asmx" />

If this is not possible with straight html and javascript, can someone show me a stand-alone php page that would do it?

Best Solution

See this link:


Use JQuery


Essentially, you make your Web Service script callable, just an attribute in your Web Service definition and you do:

    type: "POST",
    url: "~/MyService.asmx/MyMethod",
    data: "{parameterName:'" aStringArgument + "'}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(msg) {
       var data = msg.d
       // Now var is an object with properties just like your object