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

asp.netjsonweb-services

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">
    <Services>
        <asp:ServiceReference Path="~\MyService.asmx" />
    </Services>
</asp:ScriptManager>

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:

http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/

Use JQuery

www.jquery.org

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

  $.ajax({
    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
    }
  });