<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Amit Yadav &#187; JQuery</title>
	<atom:link href="http://www.amityadav.name/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.amityadav.name</link>
	<description>Things to know for effective coding</description>
	<lastBuildDate>Fri, 19 Aug 2011 17:51:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>jQuery Custom Alertbox Plugin</title>
		<link>http://www.amityadav.name/jquery-custom-alertbox-plugin/</link>
		<comments>http://www.amityadav.name/jquery-custom-alertbox-plugin/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 16:52:44 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=449</guid>
		<description><![CDATA[I was working on an app using Adobe AIR platform. At one stage i was at a point where i needed an alert system that i can customize according to my needs. I searched for some of the plugins that were very good but accidently i bumped into a link where it talks about how [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on an app using Adobe AIR platform. At one stage i was at a point where i needed an alert system that i can customize according to my needs. I searched for some of the plugins that were very good but accidently i bumped into a link where it talks about how to create a jQuery plugin, so i thought of creating my own which i can customize according to my needs.<br />
I am providing the code here so that you can use this code and customize it according to your need.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p449code2'); return false;">View Code</a> SCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4492"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code" id="p449code2"><pre class="script" style="font-family:monospace;">//PLUGIN FOR THE NEW ALERT BOX
 (function($){  
	 $.fn.extend({   
		 customAlert: function(options) {
			var htmlStr = '&lt;div id=&quot;amitOverlay&quot;&gt;&lt;/div&gt;&lt;div id=&quot;alertMsgDiv&quot;&gt;&lt;div id=&quot;aClose&quot;&gt;[X]&lt;/div&gt;&lt;div id=&quot;aMessage&quot;&gt;&lt;/div&gt;&lt;/div&gt;';
			var defaults = {   
				 bgColor: '#000',  
				 opacity: '0.6',  
				 message: 'This is a test message from the plugin',  
			 };  
&nbsp;
			var options = $.extend(defaults, options);  
			$(&quot;body&quot;).append(htmlStr);
			$(&quot;#alertMsgDiv&quot;).css({'display': 'block', 'width': '100px'});
			$(&quot;#amitOverlay&quot;).css({'display': 'block', 'top': '0px', 'left': '0px', 'width': $(this).width() + &quot;px&quot;, 'height': $(this).height() + &quot;px&quot;, 'background-color': options.bgColor, 'opacity': options.opacity});	
&nbsp;
			$(&quot;#aMessage&quot;).html(options.message);
			$(&quot;#alertMsgDiv&quot;).animate({width: 300}, 300);
&nbsp;
			$(&quot;#amitOverlay, #aClose&quot;).click(function(){	
				$(&quot;#alertMsgDiv&quot;).remove();
				$(&quot;#amitOverlay&quot;).remove();									
			});
		 }  
	 });  
 })(jQuery);
&nbsp;
&nbsp;
/*
 USAGE
 $(document).ready(function(){
	$(document).customAlert({opacity:0.4, bgColor: &quot;#aaa&quot;,  message: 'This is a test message' });
 });
 */</pre></td></tr></table></div>

<div>Download the code <a title="Code" href="http://amityadav.name/customAlert.rar" target="_blank">here</a></div>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><img class="zemanta-pixie-img" style="border: none; float: right;" src="http://img.zemanta.com/pixy.gif?x-id=e1d2ec40-6735-4b17-acf0-a009f6050a0a" alt="" /><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fjquery-custom-alertbox-plugin%2F&amp;title=jQuery%20Custom%20Alertbox%20Plugin" id="wpa2a_2"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/jquery-custom-alertbox-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>QUnit:JavaScript Testing Framework</title>
		<link>http://www.amityadav.name/qunitjavascript-testing-framework/</link>
		<comments>http://www.amityadav.name/qunitjavascript-testing-framework/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 07:07:40 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[QUnit]]></category>
		<category><![CDATA[Unit testing]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=401</guid>
		<description><![CDATA[QUnit is a powerful JavaScript unit testing framework that helps you to debug code. It&#8217;s written by members of the jQuery team, and is the official test suite for jQuery. But QUnit is general enough to test any regular JavaScript code, and it&#8217;s even able to test server-side JavaScript via some JavaScript engine like Rhino [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://docs.jquery.com/QUnit">QUnit</a> is a powerful  <a class="zem_slink" title="JavaScript" rel="wikipedia" href="http://en.wikipedia.org/wiki/JavaScript">JavaScript</a> <a class="zem_slink" title="Unit testing" rel="wikipedia" href="http://en.wikipedia.org/wiki/Unit_testing">unit testing</a> framework that helps you to debug code. It&#8217;s  written by members of the <a href="http://jquery.com/">jQuery</a> team,  and is the official <a class="zem_slink" title="Test suite" rel="wikipedia" href="http://en.wikipedia.org/wiki/Test_suite">test suite</a> for jQuery. But QUnit is general enough  to test any regular JavaScript code, and it&#8217;s even able to test  server-side JavaScript via some JavaScript engine like Rhino or V8.</p>
<p>If you&#8217;re unfamiliar with the idea of &#8220;unit testing&#8221;, don&#8217;t worry.  It&#8217;s not too difficult to understand:</p>
<blockquote><p><em>In <a class="zem_slink" title="Computer programming" rel="wikipedia" href="http://en.wikipedia.org/wiki/Computer_programming">computer programming</a>, unit testing is a <a class="zem_slink" title="Software verification" rel="wikipedia" href="http://en.wikipedia.org/wiki/Software_verification">software  verification</a> and validation method in which a programmer tests if  individual units of <a class="zem_slink" title="Source code" rel="wikipedia" href="http://en.wikipedia.org/wiki/Source_code">source code</a> are fit for use. A unit is the smallest  testable part of an <a class="zem_slink" title="Computer software" rel="wikipedia" href="http://en.wikipedia.org/wiki/Computer_software">application</a>. In <a class="zem_slink" title="Procedural programming" rel="wikipedia" href="http://en.wikipedia.org/wiki/Procedural_programming">procedural</a> programming a unit may be  an individual function or procedure.</em></p></blockquote>
<p>This is quoted from Wikipedia. Simply put, you write tests for each  functionality of your code, and if all of these tests are passed, you  can be sure that the code will be bug-free (mostly, depends on how  thorough your tests are).</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/pixy.gif?x-id=e724939f-b2c3-4f20-94a2-a746f45ee97f" alt="" /><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fqunitjavascript-testing-framework%2F&amp;title=QUnit%3AJavaScript%20Testing%20Framework" id="wpa2a_4"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/qunitjavascript-testing-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using JQuery &amp; Prototype together</title>
		<link>http://www.amityadav.name/using-jquery-prototype-together/</link>
		<comments>http://www.amityadav.name/using-jquery-prototype-together/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 19:25:47 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[Prototype JavaScript Framework]]></category>
		<category><![CDATA[Yui]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=255</guid>
		<description><![CDATA[You would surely have used JQuery and Prototype for dynamic web applications like Lightview, Prototip, etc. Here i would show you how to user them two together, on the same page. Problem The Problem JQuery uses a “$” as a shortcut for “jQuery” and Prototype uses “$” as well. We can’t have JQuery and Prototype [...]]]></description>
			<content:encoded><![CDATA[<p>You would surely have used JQuery and <a class="zem_slink" title="Prototype JavaScript Framework" rel="homepage" href="http://prototypejs.org">Prototype</a> for dynamic web applications like Lightview, Prototip, etc. Here i would show you how to user them two together, on the same page.</p>
<p><strong>Problem</strong><br />
The Problem JQuery uses a “$” as a shortcut for “jQuery” and Prototype uses “$” as well. We can’t have JQuery and Prototype using the same “$” namespace.</p>
<p><strong>The Fix</strong><br />
Thankfully JQuery has a neat little function called jQuery.noConflict( ) which you basically just need to stick at the top of your JQuery file and replace the “$” alias with “jQuery” for each function. Example:</p>
<p><span style="color: #800000;">jQuery.noConflict();<br />
// Do something with jQuery<br />
jQuery(&#8220;div p&#8221;).hide();<br />
// Do something with another library&#8217;s $()<br />
$(&#8220;content&#8221;).style.display = &#8216;none&#8217;;</span></p>
<p>Of course, there are other ways of solving this issue with jQuery.noConflict( )</p>
<p>NOTE: JQuery doesn’t get along with <a class="zem_slink" title="MooTools" rel="homepage" href="http://mootools.net">MooTools</a> and <a class="zem_slink" title="Yui (singer)" rel="imdb" href="http://www.imdb.com/name/nm2065262/">YUI</a> very well either, luckily this can also be solved with the jQuery.noConflict( ) trick.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/pixy.gif?x-id=f1a1174b-f24b-48cf-aa25-44bd8eaa905d" alt="" /><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fusing-jquery-prototype-together%2F&amp;title=Using%20JQuery%20%26%23038%3B%20Prototype%20together" id="wpa2a_6"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/using-jquery-prototype-together/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parse JSON with jQuery and JavaScript</title>
		<link>http://www.amityadav.name/parse-json-with-jquery-and-javascript/</link>
		<comments>http://www.amityadav.name/parse-json-with-jquery-and-javascript/#comments</comments>
		<pubDate>Wed, 02 Apr 2008 05:54:30 +0000</pubDate>
		<dc:creator>Amit</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JSON]]></category>

		<guid isPermaLink="false">http://www.amityadav.name/?p=6</guid>
		<description><![CDATA[Believe me that the javascript libraries available for user have helped speed up the work to great extent, and they are browser independent. Every time i wrote a javascript code i have to check whether its working on different browsers or not, but thses libraries came and saved me from doing all those difficult work. [...]]]></description>
			<content:encoded><![CDATA[<p>Believe me that the javascript libraries available for user have helped speed up the work to great extent, and they are browser independent.</p>
<p>Every time i wrote a javascript code i have to check whether its working on different browsers or not, but thses libraries came and saved me from doing all those difficult work.</p>
<p>Here i had a requirement of parsing a JSON with jQuery for my project, i had no idea whatsoever about doing this, but ultimately <a title="Parse JSON with jQuery" href="http://blog.reindel.com/2007/10/02/parse-json-with-jquery-and-javascript/" target="_blank">this</a> article saved me, i really thank him for the code. Here i will tell you people how to do that.</p>
<p>Here is the JSON object that we will be parsing.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6code6'); return false;">View Code</a> SCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p66"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p6code6"><pre class="script" style="font-family:monospace;">{attributes:[{title: &quot;Project Delivered&quot;, post_id: 31, post_type_id: 5, parent_post_id: null, description: &quot;Working&quot;, time_zone: &quot;International Date Line West&quot;, user_id: 4, image_path: &quot;http://localhost:3000/user/image_path/4/thumb/3.jpg&quot;, user_name: &quot;TestUser1&quot;, created_at: &quot;Thu Mar 27 04:29:33 UTC 2008&quot;, email: &quot;testuser1@testurl.com&quot;},{title: &quot;Task Response&quot;, post_id: 45, post_type_id: 6, parent_post_id: null, description: &quot;completed&quot;, time_zone: &quot;International Date Line West&quot;, user_id: 3, image_path: &quot;http://localhost:3000/user/image_path/3/thumb/2.jpg&quot;, user_name: &quot;TestUser2&quot;, created_at: &quot;Fri Mar 28 06:13:49 UTC 2008&quot;, email: &quot;testuser2@testurl.com&quot;},{title: &quot;abhijats post&quot;, post_id: 58, post_type_id: 1, parent_post_id: 55, description: &quot;&quot;, time_zone: &quot;International Date Line West&quot;, user_id: 2, image_path: &quot;http://localhost:3000/user/image_path/2/thumb/9.jpg&quot;, user_name: &quot;TestUser3&quot;, created_at: &quot;Fri Mar 28 11:37:16 UTC 2008&quot;, email: &quot;testuser3@testurl.com&quot;},{title: &quot;Give demo&quot;, post_id: 41, post_type_id: 4, parent_post_id: null, description: &quot;\074strong\076Give demo\074/strong\076&quot;, time_zone: &quot;Paris&quot;, user_id: 1, image_path: &quot;http://localhost:3000/user/image_path/1/thumb/mazewallpaperv2.jpg&quot;, user_name: &quot;TestUser4&quot;, created_at: &quot;Fri Mar 28 06:04:02 UTC 2008&quot;, email: &quot;testuser4@testurl.com&quot;},{title: &quot;Status Update&quot;, post_id: 37, post_type_id: 5, parent_post_id: null, description: &quot;Working&quot;, time_zone: &quot;Paris&quot;, user_id: 1, image_path: &quot;http://localhost:3000/user/image_path/1/thumb/mazewallpaperv2.jpg&quot;, user_name: &quot;TestUser4&quot;, created_at: &quot;Fri Mar 28 05:20:37 UTC 2008&quot;, email: &quot;testuser4@testurl.com&quot;},
&nbsp;
{title: &quot;abhijat has read acess&quot;, post_id: 57, post_type_id: 1, parent_post_id: 55, description: &quot;&quot;, time_zone: &quot;Paris&quot;, user_id: 1, image_path: &quot;http://localhost:3000/user/image_path/1/thumb/mazewallpaperv2.jpg&quot;, user_name: &quot;AbhilashKumar&quot;, created_at: &quot;Fri Mar 28 11:16:50 UTC 2008&quot;, email: &quot;testuser4@testurl.com&quot;},
&nbsp;
{title: &quot;Inxero&quot;, post_id: 48, post_type_id: 2, parent_post_id: null, description: &quot;Inxero&quot;, time_zone: &quot;Paris&quot;, user_id: 1, image_path: &quot;http://localhost:3000/user/image_path/1/thumb/mazewallpaperv2.jpg&quot;, user_name: &quot;TestUser4&quot;, created_at: &quot;Fri Mar 28 06:56:28 UTC 2008&quot;, email: &quot;testuser4@testurl.com&quot;},
&nbsp;
{title: &quot;New public porjet&quot;, post_id: 50, post_type_id: 2, parent_post_id: null, description: &quot;&quot;, time_zone: &quot;Paris&quot;, user_id: 1, image_path: &quot;http://localhost:3000/user/image_path/1/thumb/mazewallpaperv2.jpg&quot;, user_name: &quot;TestUser4&quot;, created_at: &quot;Fri Mar 28 10:30:04 UTC 2008&quot;, email: &quot;testuser4@testurl.com&quot;},
&nbsp;
{title: &quot;Status Update&quot;, post_id: 35, post_type_id: 5, parent_post_id: null, description: &quot;Hey the stuff is coming good&quot;, time_zone: &quot;Paris&quot;, user_id: 1, image_path: &quot;http://localhost:3000/user/image_path/1/thumb/mazewallpaperv2.jpg&quot;, user_name: &quot;TestUser4&quot;, created_at: &quot;Fri Mar 28 01:50:48 UTC 2008&quot;, email: &quot;testuser4@testurl.com&quot;},
&nbsp;
{title: &quot;Status Update&quot;, post_id: 36, post_type_id: 5, parent_post_id: null, description: &quot;kljklkl&quot;, time_zone: &quot;Paris&quot;, user_id: 1, image_path: &quot;http://localhost:3000/user/image_path/1/thumb/mazewallpaperv2.jpg&quot;, user_name: &quot;TestUser4&quot;, created_at: &quot;Fri Mar 28 01:59:08 UTC 2008&quot;, email: &quot;testuser4@testurl.com&quot;}]}</pre></td></tr></table></div>

<p>Here is the JSON parser that will parse the JSON object. <em><br />
this parser uses $.getJSON()</em> method, with a call to the JSON object file, and a function to pass the data through for parsing.The common <em>$.each()</em> method in jQuery can be used to traverse the &#8220;nodes&#8221; (keys) that you indicate.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6code7'); return false;">View Code</a> SCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p67"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
</pre></td><td class="code" id="p6code7"><pre class="script" style="font-family:monospace;">$(function(url) {
	$.getJSON(&quot;jsonObj.js&quot;, function(json) {
&nbsp;
		/* Parse JSON objects */
		jJSON[&quot;title&quot;] = (function() {
			response = {
				values: [],
				count: 0
			};
			$.each(json.attributes,function(i,item) {
				if (item.title != &quot;undefined&quot; &amp;amp;&amp;amp; item.title != &quot;&quot;) {
					response.count++;
					response.values[i] = item.title;
				}
			});
			return response;
		})();
&nbsp;
		jJSON[&quot;email&quot;] = (function() {
			response = {
				values: [],
				count: 0
			};
			$.each(json.attributes,function(i,item) {
				if (item.email != &quot;undefined&quot;) {
					response.count++;
					response.values[i] = item.email;
				}
			});
			return response;
		})();
&nbsp;
		jJSON[&quot;created_at&quot;] = (function() {
			response = {
				values: [],
				count: 0
			};
			$.each(json.attributes,function(i,item) {
				if (item.created_at != &quot;undefined&quot;) {
					response.count++;
					response.values[i] = item.created_at;
				}
			});
			return response;
		})();
&nbsp;
		jJSON[&quot;image_path&quot;] = (function() {
			response = {
				values: [],
				count: 0
			};
			$.each(json.attributes,function(i,item) {
				if (item.image_path != &quot;undefined&quot;) {
					response.count++;
					response.values[i] = item.image_path;
				}
			});
			return response;
		})();
&nbsp;
		jJSON[&quot;project_name&quot;] = (function() {
			response = {
				values: [],
				count: 0
			};
			$.each(json.attributes,function(i,item) {
				if (item.image_path != &quot;undefined&quot;) {
					response.count++;
					response.values[i] = item.project_name;
				}
			});
			return response;
		})();
&nbsp;
		/* Function to show data sreams */
&nbsp;
		displaySocialStream = function() {
			var displayDiv = $('#post_wrapper');
			var dumpP;
			var str = '';
			for(strmCntr =0; strmCntr &lt; (jJSON[&quot;title&quot;][&quot;values&quot;].length - 1); strmCntr++){
				if(strmCntr/2 == 0)
				{
					postClass = &quot;post&quot;;
				}else{
					postClass = &quot;post alternate-post&quot;;
				}
&nbsp;
				str = str + '&lt;div class=&quot;' + postClass + '&quot;&gt;&lt;div class=&quot;avatar&quot;&gt;&lt;img src=&quot;' + jJSON[&quot;image_path&quot;][&quot;values&quot;][strmCntr]  + '&quot; class=&quot;avatar-image&quot;/&gt;&lt;/div&gt;&lt;div class=&quot;post-content&quot;&gt;&lt;b&gt;Created At:&lt;/b&gt; ' + jJSON[&quot;created_at&quot;][&quot;values&quot;][strmCntr] + '&lt;br /&gt; &lt;b&gt;Project Name:&lt;/b&gt;' + jJSON[&quot;project_name&quot;][&quot;values&quot;][strmCntr]  + '&lt;br /&gt; &lt;b&gt;Post Title:&lt;/b&gt; ' + jJSON[&quot;title&quot;][&quot;values&quot;][strmCntr]  + '&lt;br /&gt; &lt;b&gt;Email:&lt;/b&gt; &lt;a href=&quot;mailto:' + jJSON[&quot;email&quot;][&quot;values&quot;][strmCntr]  + '&quot;&gt;' + jJSON[&quot;email&quot;][&quot;values&quot;][strmCntr]  + '&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;';
			}
			displayDiv.prepend(str);
		};
		displaySocialStream();
&nbsp;
	});
}
)</pre></td></tr></table></div>

<p>At first glance it seems I could have refined each reference to a self-invoking function into a single function call. However, you must consider that grabbing data from XML is quite different than grabbing data from JSON. While there is still a parent/child relationship, a child in JSON could be a different type, like an array. There might be several arrays throughout the structure. Simply using the dot operator becomes impossible, and getting different keys can be a unique process.</p>
<p>Each key in jJSON references another hash object with two keys, called values and count. Accessing values will return an array of values, and count will tell you how many of that particular reference exists. For example, how many &#8220;title&#8221;or &#8220;email&#8221; key references were obtained from the JSON.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6code8'); return false;">View Code</a> SCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p68"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="p6code8"><pre class="script" style="font-family:monospace;">var jJSON = {
    getValues: function(obj,num) {
        return jJSON[obj][&quot;values&quot;].slice(0,((num == null) ? jJSON[obj][&quot;values&quot;].length : num));
    },
    getCount: function(obj) {
        return jJSON[obj][&quot;count&quot;];
    },
    getRandomValues: function(obj,num) {
        var a = [];
        var b = jJSON[obj][&quot;values&quot;];
        var c = b.length;
        if (num != null &amp;&amp; num &amp;lt; c) {
            c = num;
        }
        for (i = 0; i &lt; c; i++) {
            var e = Math.floor(Math.random() * b.length);
            a[i] = b[e];
            b.splice(e,1);
        }
        return a;
    }
};</pre></td></tr></table></div>

<p>Along with the key references added to the jJSON object, there are three helper methods. The getValues method will return a number of values for a given object key as an array. If you pass in null as the second parameter, you will receive all values. The getCount method will return a count for a given object key. Finally, the getRandomValues will return a number of randomized values for a given object key.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.amityadav.name%2Fparse-json-with-jquery-and-javascript%2F&amp;title=Parse%20JSON%20with%20jQuery%20and%20JavaScript" id="wpa2a_8"><img src="http://www.amityadav.name/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.amityadav.name/parse-json-with-jquery-and-javascript/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

