Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Iterate Through jQuery String Object / Loop through jQuery String / Object using jQuery

Jul 16, 2013
Introduction

Here I will explain how to iterate through jQuery string / object using jQuery or loop through jQuery string / object using jQuery.

Description:

In previous articles I explained jQuery Hover dropdown menu with css, jQuery show modal popup window on pageload, jQuery open videos in modal popup window,  jQuery Show gridview row details on mouseover, jQuery Draggable & Resizable div with example and many articles relating to JQuery, JavaScript, asp.net, code snippets. Now I will explain how to iterate through jQuery string / object using jQuery or loop through jQuery string / object using jQuery.

Code to iterate through JSON object

To iterate through JSON object or string we need to write the code like as shown below


var str = { "UserDetails": [{ "Name": "Suresh", "Location": "Chennai" }, { "Name": "Rohini", "Location": "Guntur" }, { "Name": "Mahesh", "Location": "Nuzividu" }, { "Name": "Madhav", "Location": "NAGPUR" }, { "Name": "Nagaraju", "Location": "Hyderabad" }, { "Name": "Kapil", "Location": "Malaysia" }] };
$(str.UserDetails).each(function(i, e) {
alert(e.Name);
});
If you want to see it in complete example check below code


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<title>jQuery Loop Through JSON Object</title>
<script type="text/javascript">
$(function() {
var str = { "UserDetails": [{ "Name": "Suresh", "Location": "Chennai" }, { "Name": "Rohini", "Location": "Guntur" }, { "Name": "Mahesh", "Location": "Nuzividu" }, { "Name": "Madhav", "Location": "NAGPUR" }, { "Name": "Nagaraju", "Location": "Hyderabad" }, { "Name": "Kapil", "Location": "Malaysia" }] };
$(str.UserDetails).each(function(i, e) {
alert(e.Name);
});
})
</script>
</head>
<body>
<div>
</div>
</body>
</html>
Live Demo

For live demo click on below button to see the above string values





If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

1 comments :

Anonymous said...

good one

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.