Sunday, July 11, 2010

How To call a Web service in javascript

By Using jQuery

    var params = "{'id':'123','name':'josh'}";

    $(document).ready(function()
    {
        $.ajax({
            type: "POST",
            url: "/WebService/aspnet_service.asmx/getUserInfoFunc",
            data: params,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg)
            {
                alert(msg.d);
            }
            ,
            error: function(result)
            {
                alert(result.status + ":" + result.statusText);
            }
        });
    });

No comments: