Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Sample Json String:-

{d: "{"name":{"Fname":"test","LName":"data"},"Address":{"address1":"abc","address2":"def","pincode":"0","Area":"Bhandup"}}"}

Name data should be append in
table an address data should be append in
table kindly help

What I have tried:

<pre><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JsonDisplay.aspx.cs" Inherits="JSON1.JsonDisplay" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
    <script src="Scripts/jquery-2.1.4.js"></script>
   <%-- <script src="Scripts/jquery-2.1.4.min.js"></script>--%>
    <script type="text/javascript">
        $(document).ready(function () {

            $('#Getdata').click(function () {


                type: "POST",
                url: "JsonDisplay.aspx/DisplayData",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                data: { },
                   success: function (msg) {
                       var data = JSON.stringify(msg);
                       var jdata = JSON.parse(data);

                       var i = 0;

                       var trHTML = '';

                       $.each(jdata, function (i, item) {
                             trHTML += '<tr><td>' + data.jdata[i] + '</td><td>' + data.jdata[i] + '</td></tr>';

    <form id="form1" runat="server">
        <%--<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />--%>
       <input type="button" name="btn1" id="Getdata" value="Getdata" />
        <div id="name">
            <table id="tblname">

        <div id="Addess">
            <table id="tblAddress">

Updated 1-Feb-19 20:23pm
[no name] 4-Feb-19 12:15pm    
Thanks for reminding me again why I don't do web clients.
Richard Deeming 4-Feb-19 12:50pm    
var data = JSON.stringify(msg);
var jdata = JSON.parse(data);


1. jQuery takes the JSON returned from the server, and parses it into an object for you.
2. You than convert that object back to JSON.
3. You then parse that JSON back into an object.

Just use the msg parameter instead.
Richard Deeming 4-Feb-19 12:51pm    
trHTML += '<tr><td>' + data.jdata[i] + '</td><td>' + data.jdata[i] + '</td></tr>';

Your data variable is a string. It doesn't have a property called jdata.
dattaprasaddhuri 8-Feb-19 0:16am    
Thank you. Its working

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