Pages

Friday, 7 June 2013

How To Make jQuery Read and Parse JSON String using ParseJSON Method in C# Asp.Net

How To Make jQuery Read and Parse JSON String using ParseJSON Method in C# Asp.Net


Program:

.Aspx File:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Read and Parse Data using ParseJSON method</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(function () {
        var name = '';
        var jsonstr = '[{"UserName":"Sizar","UserID":"1"},{"UserName":"surani","UserID":"2"}]';
        var obj = $.parseJSON(jsonstr);
        $.each(obj, function () {
            name += this['UserName'] + "<br/>";
        });
        $('#divjson').html(name); ;
    })
</script>
</head>
<body>
<div id="divjson">
</div>
</body>
</html>

Live Demo:

jQuery Read and Parse Data using ParseJSON method

No comments:

Post a Comment