Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
1.11/5 (3 votes)
Hello friends ... i am new 8n web servicees in asp.net . Can anyone tell me how to use JSON formate to send and recieve data instead of XML . Please send me a link from where i can get batter concept. Thanks in advance
Posted
Comments
Mathi Mani 24-May-15 2:06am    
What do you mean by webservice? Legacy web service, WCF or Asp.Net WebAPI?
ZurdoDev 24-May-15 12:22pm    
Lots of examples online. Where are you stuck exactly?

1 solution

Hope you want to call json from your aspx page. if it so, then use this code.

<script type="text/javascript">
        function GetDescription(a) {
            // alert(a); // the dropdown item selected value
            $.ajax({
                type: 'POST',
                contentType: "application/json; charset-8;",
                url: 'WT.aspx/GetRef', //here you can call your webservice & its method
                data: '{ id:' + a + '}',//pass arguments
                success: OnSuccess,
                error: function (data) {//webservice which returns data
                    alert(data.d);
                }

            });

            function OnSuccess(data) {//binding to the controls
                var abc = data.d;
                var desc, unitprice, sp;
                sp = abc.split("|");

                $("#<%=lbldesc.ClientID %>").text(sp[0]);
                $("#<%=hdndesc.ClientID %>").val(sp[0]);
                $("#<%=lbltunitprice.ClientID %>").text(sp[1]);
                $("#<%=hdntunitprice.ClientID %>").val(sp[1]);

            }

        }


    </script>


hope this would help you.

All The Best
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900