Click here to Skip to main content
16,011,988 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi
Since i am new to json i need to know what is json and also the post method of json
and also there is a requirement in which i have certain data in dataset ans i have converted it to json using
C#
string strjson = string.Empty;
strjson = Newtonsoft.Json.JsonConvert.SerializeObject(dsGetdetails);

and the output(json) look like the below one
C#
{"Table":[{"businessName":"Name","businessId":1234},{"businessName":"Name","businessId":1234}]}

now how to use the above json in the jvascript and use the post method
Posted
Updated 22-Feb-12 17:53pm
v2

1 solution

Have a look at this:
Bind Gridview using Jquery[^]
This tutorial will show how to bind json data in Gridview
XML
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
</script>
<script type="text/javascript">
  function BindGridView() {
     $.ajax({
          type: "POST",
          url: "Default.aspx/GetNames",
          data: "{}",
          contentType: "application/json",
          dataType: "json",
          success: function (data) {
         for (var i = 0; i < data.d.length; i++) {
                $("#NamesGridView").append("<tr><td>" + data.d[i].FirstName +
                                        "</td><td>" + data.d[i].Age + 
                                        "</td></tr>");
             }
           }
          })
      }
</script>
 
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