<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8493420257810053635</id><updated>2024-09-14T06:49:39.286-07:00</updated><title type='text'>Learn Jquery</title><subtitle type='html'>Learn Jquery in easy way - JQuery Useful links - JQuery Pluggins - JQuery functions - JQuery examples - JQuery Reference</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jquery-4u.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://jquery-4u.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>gouse</name><uri>http://www.blogger.com/profile/13059729325413820275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>11</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8493420257810053635.post-1109641684382385300</id><published>2010-09-17T11:06:00.000-07:00</published><updated>2010-09-17T11:07:14.922-07:00</updated><title type='text'>Get URL parameters &amp;amp; values with jQuery</title><content type='html'>&lt;p&gt;In this post, I would like to share a little jQuery code snippet that makes &lt;strong&gt;getting URL parameters and their values more convenient&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;Recently, while working on one of my projects, I needed to read and get parameter values from URL string of the current page that was constructed and sent by PHP script. I came across this short and sweet JavaScript code snippet by &lt;a rel=&quot;nofollow&quot; href=&quot;http://snipplr.com/users/Roshambo/&quot;&gt;Roshambo&lt;/a&gt; that does just that.&lt;/p&gt;  &lt;pre class=&quot;prettyprint lang-js&quot;&gt;&lt;span class=&quot;com&quot;&gt;// Read a page&#39;s GET URL variables and return them as an associative array.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; getUrlVars&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; vars &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;[],&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; hash&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; hashes &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; window&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;?&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;&amp;amp;&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; i &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; i &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; hashes&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; i&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;++)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;        hash &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; hashes&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;=&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;        vars&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;hash&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;]);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;        vars&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;hash&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; hash&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;];&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; vars&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;The function returns an array/object with your URL parameters and their values. For example, consider we have the following URL:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;prettyprint lang-html&quot;&gt;&lt;span class=&quot;pln&quot;&gt;http://www.example.com/?me=myValue&amp;amp;name2=SomeOtherValue&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Calling &lt;code&gt;getUrlVars()&lt;/code&gt; function would return you the following array:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;prettyprint lang-js&quot;&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&quot;me&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&quot;myValue&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&quot;name2&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&quot;SomeOtherValue&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;To get a value of first parameter you would do this:&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; white-space: pre; &quot;&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; first &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; getUrlVars&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()[&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&quot;me&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre class=&quot;prettyprint lang-js&quot;&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// To get the second parameter&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; second &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; getUrlVars&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()[&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&quot;name2&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;];&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;To make the script syntax to look more jQuery like syntax I rewrote it as an extension for jQuery:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;prettyprint lang-js&quot;&gt;&lt;span class=&quot;pln&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;  getUrlVars&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; vars &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;[],&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; hash&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; hashes &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; window&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;?&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;&amp;amp;&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; i &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; i &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; hashes&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; i&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;++)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;      hash &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; hashes&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;=&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;      vars&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;hash&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;]);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;      vars&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;hash&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;]]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; hash&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;];&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; vars&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;  getUrlVar&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; $&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getUrlVars&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;];&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;});&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;Now, if you include the above code in your javascript file, you can get URL parameter values in the following way:&lt;/p&gt;&lt;pre class=&quot;prettyprint lang-js&quot;&gt;&lt;span class=&quot;com&quot;&gt;// Get object of URL parameters&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; allVars &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; $&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getUrlVars&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// Getting URL var by its nam&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; byName &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; $&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getUrlVar&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;name&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;/pre&gt;&lt;ol&gt;&lt;br /&gt;&lt;/ol&gt;&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jquery-4u.blogspot.com/feeds/1109641684382385300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/get-url-parameters-values-with-jquery.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/1109641684382385300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/1109641684382385300'/><link rel='alternate' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/get-url-parameters-values-with-jquery.html' title='Get URL parameters &amp;amp; values with jQuery'/><author><name>gouse</name><uri>http://www.blogger.com/profile/13059729325413820275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8493420257810053635.post-8399214536546003708</id><published>2010-09-17T11:05:00.000-07:00</published><updated>2010-09-17T11:06:02.852-07:00</updated><title type='text'>Create callback functions for your jQuery plugins &amp;amp; extensions</title><content type='html'>&lt;p&gt;&lt;br /&gt;Most of the time custom jQuery plugins and extensions that we create do not use a callback functions. They usually simply work on DOM elements or do some calculations. But there are cases when we need to define &lt;strong&gt;our own  custom callback functions for our plugins&lt;/strong&gt;. And this is especially true when our plugins utilize AJAX querying.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Let’s say our custom jQuery extension gets data by making some AJAX request.&lt;/p&gt;&lt;br /&gt;&lt;pre class=&quot;prettyprint lang-js&quot;&gt;&lt;span class=&quot;pln&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; myFunc &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;someArg&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; url &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&quot;http://site.com?q=&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; someArg&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; $&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getJSON&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// our function definition hardcoded&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;});&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;});&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;What is bad in this jQuery code is that the callback function is defined and hardcoded right in the plugin itself. The plugin is not really flexible and its user will have to change the plugin code, which is bad!&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;So the solution is to define your own custom callback function argument. Here is how it is done:&lt;/p&gt;&lt;br /&gt;&lt;pre class=&quot;prettyprint&quot;&gt;&lt;span class=&quot;pln&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; myFunc &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;someArg&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; callbackFnk&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; url &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&quot;http://site.com?q=&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; someArg&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; $&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getJSON&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// now we are calling our own callback function&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;typeof&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; callbackFnk &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;function&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; callbackFnk&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; data&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;});&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;});&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;br&gt;$&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;myFunc&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// now my function is not hardcoded&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// in the plugin itself&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;});&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;The above code shows you how to create a callback function for AJAX load, but if you want to create a &lt;strong&gt;simple callback function for your jQuery plugin&lt;/strong&gt;, for example the one that executes on your own custom events. To achive this you can do the following:&lt;/p&gt;&lt;br /&gt;&lt;pre class=&quot;prettyprint&quot;&gt;&lt;span class=&quot;pln&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;extend&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; myFunc &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;someArg&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; callbackFnk&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// do something here&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; data &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;test&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// now call a callback function&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;typeof&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; callbackFnk &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;function&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; callbackFnk&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; data&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;});&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;br&gt;$&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;myFunc&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;someArg&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;arg&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// now my function is not hardcoded&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// in the plugin itself&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// and arg = &#39;test&#39;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;});&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jquery-4u.blogspot.com/feeds/8399214536546003708/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/create-callback-functions-for-your.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/8399214536546003708'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/8399214536546003708'/><link rel='alternate' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/create-callback-functions-for-your.html' title='Create callback functions for your jQuery plugins &amp;amp; extensions'/><author><name>gouse</name><uri>http://www.blogger.com/profile/13059729325413820275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8493420257810053635.post-4288036651214835901</id><published>2010-09-17T11:04:00.000-07:00</published><updated>2010-09-17T11:05:15.699-07:00</updated><title type='text'>Cross-domain RSS to JSON converter [jQuery plugin]</title><content type='html'>&lt;p&gt;No doubt that Web2.0 is one of the best things that happened in our lifetime (besides the internet itself). When we mention Web2.0 first things that come into our minds are AJAX, rounded corners, clean and light layouts and of course RSS feeds. Nowadays, you either provide an RSS feed or consume it in your web app using AJAX/JavaScript.&lt;/p&gt;  &lt;p&gt;The only bad thing is that you can not request cross-site content with AJAX requests. Requesting someone else’s RSS in your JavaScript falls into this limitations. One way to overcome this problem is to apply a &lt;a href=&quot;http://jquery-4u.blogspot.com/2009/04/cross-domain-ajax-querying-with-jquery.html&quot; title=&quot;Cross-domail AJAX quering&quot;&gt;server-side proxy workaround&lt;/a&gt;. However, there is even better solution and workaround &amp;ndash; &lt;strong&gt;RSS to JSON conversion&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;Basically, using &lt;a href=&quot;http://jquery-4u.blogspot.com/2009/05/google-feeds-api-jquery-plugin.html&quot; title=&quot;jQuery plugin for Google Feeds API&quot;&gt;Google Feeds API service and jQuery plugin&lt;/a&gt; you can request and get any RSS from different domain converted into the JSON object in your javascript.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Let’s see an example of RSS2JSON converter:&lt;/strong&gt;&lt;/p&gt;  &lt;pre class=&quot;prettyprint lang-html&quot;&gt;&lt;span class=&quot;tag&quot;&gt;&amp;lt;script&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;atn&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot;&gt;&quot;jquery.js&quot;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;lt;script&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;atn&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;atv&quot;&gt;&quot;jquery.jgfeed.js&quot;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;lt;script&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;$&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;jGFeed&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;http://twitter.com/statuses/user_timeline/26767000.rss&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;feeds&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// Check for errors&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;feeds&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// there was an error&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// do whatever you want with feeds here&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; i&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; i&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;feeds&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;entries&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; i&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;++){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; entry &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; feeds&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;entries&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;];&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// Entry title&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; entry&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;In order to have universal client-side RSS to JSON converter you first need to include &lt;code&gt;jquery.js&lt;/code&gt; and Google Feeds API plugin &lt;code&gt;jquery.jgfeed.js&lt;/code&gt;. Then use jQuery plugin and Google Feeds API to get reliable and fast RSS to JSON(P) converter.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The code above gets Twitter RSS feeds in JSON format and does whatever it wants with it. Great workaround isn’t it :)&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;To see &lt;code&gt;jGFeed()&lt;/code&gt;’s argument lists and how to use it please &lt;a rel=&quot;nofollow&quot; href=&quot;http://jquery-4u.blogspot.com/2009/05/google-feeds-api-jquery-plugin.html&quot; title=&quot;jQuery Google Feeds API plugin&quot;&gt;read this post&lt;/a&gt;.&lt;/p&gt;  &lt;br /&gt;&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jquery-4u.blogspot.com/feeds/4288036651214835901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/cross-domain-rss-to-json-converter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/4288036651214835901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/4288036651214835901'/><link rel='alternate' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/cross-domain-rss-to-json-converter.html' title='Cross-domain RSS to JSON converter [jQuery plugin]'/><author><name>gouse</name><uri>http://www.blogger.com/profile/13059729325413820275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8493420257810053635.post-1713474550116278579</id><published>2010-09-17T11:03:00.000-07:00</published><updated>2010-09-17T11:04:04.934-07:00</updated><title type='text'>jQuery code / syntax guidelines</title><content type='html'>&lt;p&gt;We all write our own jQuery code and since &lt;a href=&quot;http://jquery-4u.blogspot.com/2008/12/how-to-create-jquery-plugin-extending.html&quot; title=&quot;Create your own jQuery Plugin&quot;&gt;creating custom jQuery plugins&lt;/a&gt; is so easy, we all create our own jQuery plugins. And all of us have our own code syntax preferences. For example:&lt;/p&gt;  &lt;pre class=&quot;prettyprint&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; myFunction&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// some prefere it like this&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; myFunction&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If you want to publish your jQuery plugins following &lt;a rel=&quot;nofollow&quot; href=&quot;http://docs.jquery.com/JQuery_Core_Style_Guidelines&quot; title=&quot;jQuery core code guidelines&quot;&gt;jQuery core code writing guidelines&lt;/a&gt; is a good idea. This would make your code more easier to read to other jQuery developers. Follow the link above and go through the guidelines (it will only take a few minutes). The guidelines page shows gives you general guidelines, but I went through the jQuery core code and &lt;strong&gt;found several &lt;/strong&gt;&lt;a href=&quot;#additional&quot;&gt;&lt;strong&gt;additional ones&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;. I lay they out at the end of this post&lt;/strong&gt;.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;In short, the official guidelines are as follows:&lt;/strong&gt; &lt;em&gt;(Taken from official docs)&lt;/em&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;Use tabs to indent your code &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Use liberal spacing&quot;: &lt;br /&gt;    &lt;pre class=&quot;prettyprint&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; myFunction &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; myVar&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; myVar2 &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// Pay attention to spaces around&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// the brackets and curly brackets&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Use strict equality checks whenever possible (===) &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Braces should always be used on blocks and statements should not be on the same line as a conditionals: &lt;br /&gt;    &lt;pre class=&quot;prettyprint&quot;&gt;&lt;span class=&quot;com&quot;&gt;// NO:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; blah&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// YES:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;blah&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;();&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;When checking an object type: &lt;br /&gt;    &lt;pre class=&quot;code&quot;&gt;String: typeof object === &quot;string&quot;&lt;br /&gt;Number: typeof object === &quot;number&quot;&lt;br /&gt;Function: jQuery.isFunction(object)&lt;br /&gt;Array: jQuery.isArray(object)&lt;br /&gt;Element: object.nodeType&lt;br /&gt;&lt;br /&gt;See full list on official docs page (link above)&lt;/pre&gt;&lt;br /&gt;  &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Don&#39;t use &lt;code&gt;&quot;string&quot;.match()&lt;/code&gt; for RegExp, instead use &lt;code&gt;.test()&lt;/code&gt; or &lt;code&gt;.exec()&lt;/code&gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Node related rules: &lt;br /&gt;    &lt;ul&gt;&lt;br /&gt;      &lt;li&gt;&lt;code&gt;.nodeName&lt;/code&gt; should always be used in favor of &lt;code&gt;.tagName&lt;/code&gt;. &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;      &lt;li&gt;&lt;code&gt;.nodeType&lt;/code&gt; should be used to determine the classification of a node (not &lt;code&gt;.nodeName&lt;/code&gt;). &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;      &lt;li&gt;Only attach data using &lt;code&gt;.data().&lt;/code&gt; &lt;/li&gt;&lt;br /&gt;    &lt;/ul&gt;&lt;br /&gt;  &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now let’s see other additional rules that I could spot reading the jQuery core code.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a name=&quot;additional&quot;&gt;&lt;/a&gt;&lt;strong&gt;Additional jQuery code / syntax guidelines:&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;The first thing that I noticed was multiline comments did not use common &lt;code&gt;/* comment */&lt;/code&gt; syntax. In jQuery core all multiline comments use line comment syntax &lt;code&gt;// comment&lt;/code&gt;. &lt;br /&gt;&lt;br /&gt;    &lt;pre class=&quot;prettyprint&quot;&gt;&lt;span class=&quot;com&quot;&gt;// This is an example of multiline&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// comment syntax used in jQuery core.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;Local variables are declared and initialized on one line just below the function declaration with no extra line: &lt;br /&gt;    &lt;pre class=&quot;prettyprint&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; someFunction &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; target &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; arguments&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{},&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; i &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; name&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// Empty line and then the rest of the code&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;When declaring objects, there is no space between property name and colon: &lt;br /&gt;    &lt;pre class=&quot;prettyprint&quot;&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; myName&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; myFunc&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{}&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;All strings are in double quotes &lt;code&gt;&quot; &quot;&lt;/code&gt;, not single quotes &lt;code&gt;&#39; &#39;&lt;/code&gt;: &lt;br /&gt;&lt;br /&gt;    &lt;pre class=&quot;prettyprint&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; myMarkup &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&quot;&amp;lt;a href=&#39;/a&#39;&amp;gt;a&amp;lt;/a&amp;gt;&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;The last but not least, variable naming uses camelCase.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;  &lt;br /&gt;&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jquery-4u.blogspot.com/feeds/1713474550116278579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/jquery-code-syntax-guidelines.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/1713474550116278579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/1713474550116278579'/><link rel='alternate' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/jquery-code-syntax-guidelines.html' title='jQuery code / syntax guidelines'/><author><name>gouse</name><uri>http://www.blogger.com/profile/13059729325413820275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8493420257810053635.post-5836867218923294605</id><published>2010-09-17T11:02:00.001-07:00</published><updated>2010-09-17T11:02:57.759-07:00</updated><title type='text'>jQuery Mobile</title><content type='html'>&lt;p&gt;jQuery Mobile is an attempt to create a javascript framework that would work on all major mobile browsers. In this post I will try to lay down all the facts that I could find about jQuery Mobile, so that you are up to date.&lt;/p&gt;  &lt;p&gt;jQuery team has mentioned that they were planning and started to work on jQuery for Mobile devices when they announced jQuery 1.4. John Resig said that they already had different mobile devices from sponsor for testing purposes. Anyway, jQuery Mobile is officially announced now, but there is a very little information about it.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Here are some facts that I found:&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;jQuery Mobile will be &lt;strong&gt;in core&lt;/strong&gt;, NOT as a separate distribution like &lt;code&gt;jquery.mobile.js&lt;/code&gt; &lt;/li&gt;    &lt;li&gt;jQuery UI team will improve current jQuery UI and develop &lt;strong&gt;new mobile components&lt;/strong&gt; (initial &lt;a rel=&quot;nofollow&quot; href=&quot;http://jquerymobile.com/designs/&quot; title=&quot;Concept design of the new jQuery UI components for mobile devices&quot;&gt;designs&lt;/a&gt;). &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Release &lt;/strong&gt;of the jQuery Mobile and new jQuery UI components is planned for October 2010. &lt;/li&gt;    &lt;li&gt;As of writing of this post, jQuery Mobile &lt;strong&gt;source code is not available&lt;/strong&gt;. The code will be pushed to the jQuery core’s &lt;a rel=&quot;nofollow&quot; href=&quot;http://github.com/jquery/jquery&quot; title=&quot;jQuery repository&quot;&gt;GitHub&lt;/a&gt; repository and announced on the official jQuery mobile &lt;a rel=&quot;nofollow&quot; href=&quot;http://jquerymobile.com&quot; title=&quot;Official jQuery Mobile homepage&quot;&gt;page&lt;/a&gt;.&lt;/li&gt;    &lt;li&gt;You can help jQuery Mobile project by testing jQuery core on your mobile devices at &lt;a rel=&quot;nofollow&quot; href=&quot;http://swarm.jquery.org/&quot; title=&quot;Test jQuery&quot;&gt;TestSwarm&lt;/a&gt;.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;That’s all I could find on jQuery Mobile for now. Subscribe to my &lt;a href=&quot;http://feeds.feedburner.com/jQueryHowto&quot; title=&quot;jQurey HowTo RSS&quot;&gt;RSS&lt;/a&gt; or follow me on &lt;a rel=&quot;nofollow&quot; href=&quot;http://twitter.com/jQueryHowto&quot; title=&quot;jQuery HowTo on Twitter&quot;&gt;Twitter&lt;/a&gt; to stay updated about news related to jQuery Mobile.&lt;/p&gt;  &lt;br /&gt;&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jquery-4u.blogspot.com/feeds/5836867218923294605/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/jquery-mobile.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/5836867218923294605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/5836867218923294605'/><link rel='alternate' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/jquery-mobile.html' title='jQuery Mobile'/><author><name>gouse</name><uri>http://www.blogger.com/profile/13059729325413820275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8493420257810053635.post-2059071296064107872</id><published>2010-09-17T11:01:00.000-07:00</published><updated>2010-09-17T11:02:07.794-07:00</updated><title type='text'>How to check loaded jQuery UI version?</title><content type='html'>&lt;p&gt;In this post I will show how to check currently loaded jQuery UI version on the page. Unlike &lt;a href=&quot;http://jquery-4u.blogspot.com/2009/02/how-to-check-jquery-version.html&quot; title=&quot;Check loaded jQuery.js version on the page&quot;&gt;checking loaded jQuery version&lt;/a&gt; ( &lt;code&gt;$().jquery&lt;/code&gt; ), checking jQuery UI version is a bit different.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Checking currently loaded jQuery UI version on the page:&lt;/strong&gt;&lt;/p&gt;  &lt;pre class=&quot;prettyprint js&quot;&gt;&lt;span class=&quot;com&quot;&gt;// Returns jQuery UI version (ex: &lt;/span&gt;&lt;em&gt;&lt;span class=&quot;com&quot;&gt;1.8.2&lt;/span&gt;&lt;/em&gt;&lt;span class=&quot;com&quot;&gt;) or &lt;/span&gt;&lt;em&gt;&lt;span class=&quot;com&quot;&gt;undefined&lt;/span&gt;&lt;/em&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;$&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;version&lt;br&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// Alternatively&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;jQuery&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;version&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You would most probably use it in the &lt;code&gt;if&lt;/code&gt; statement:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;prettyprint js&quot;&gt;&lt;span class=&quot;kwd&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// jQuery UI is loaded&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;You can also check if jQuery UI is loaded or not:&lt;/strong&gt; &lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;prettyprint js&quot;&gt;&lt;span class=&quot;com&quot;&gt;// Checking if jQuery UI is loaded or not&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;ui&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// jQuery UI is loaded&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// jQuery UI is not loaded&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;  &lt;br /&gt;&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jquery-4u.blogspot.com/feeds/2059071296064107872/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/how-to-check-loaded-jquery-ui-version.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/2059071296064107872'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/2059071296064107872'/><link rel='alternate' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/how-to-check-loaded-jquery-ui-version.html' title='How to check loaded jQuery UI version?'/><author><name>gouse</name><uri>http://www.blogger.com/profile/13059729325413820275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8493420257810053635.post-8494701689367549411</id><published>2010-09-17T11:00:00.000-07:00</published><updated>2010-09-17T11:01:14.762-07:00</updated><title type='text'>jQuery YouTube plugin demo</title><content type='html'>&lt;div&gt;&lt;div class=&quot;post-body entry-content&quot;&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;Long overdue demo for my &lt;a href=&quot;http://jquery-4u.blogspot.com/2009/05/jyoutube-jquery-youtube-thumbnail.html&quot;&gt;jQuery YouTube plugin&lt;/a&gt; &amp;ndash; jYouTube is now available &lt;a href=&quot;http://custom-drupal.com/jquery-demo/jyoutube/&quot;&gt;here&lt;/a&gt;. The plugin can fetch and get you any YouTube video’s screenshot or thumbnail by its URL or video id.&lt;/p&gt;  &lt;p&gt;Here is an example:&lt;/p&gt;  &lt;pre class=&quot;prettyprint lang-js&quot;&gt;&lt;span class=&quot;com&quot;&gt;// Getting video screenshot by YouTube video ID&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;$&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;jYoutube&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;rSUfWXcNAOw&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;com&quot;&gt;// Returns video thumbnail by YouTube video URL&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;$&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;jYoutube&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;http://www.youtube.com/watch?v=rSUfWXcNAOw&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;small&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;p&gt;By default the plugin will return URL of the video screenshot (480×360). If you just need a video thumbnail (120×90) pass an optional second parameter &quot;&lt;code&gt;small&lt;/code&gt;&quot;.&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;See the plugin in action on &lt;a rel=&quot;nofollow&quot; href=&quot;http://custom-drupal.com/jquery-demo/jyoutube/&quot; title=&quot;jQuery YouTube plugin demo&quot;&gt;jQuery YouTube demo&lt;/a&gt; page.&lt;/blockquote&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jquery-4u.blogspot.com/feeds/8494701689367549411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/jquery-youtube-plugin-demo.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/8494701689367549411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/8494701689367549411'/><link rel='alternate' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/jquery-youtube-plugin-demo.html' title='jQuery YouTube plugin demo'/><author><name>gouse</name><uri>http://www.blogger.com/profile/13059729325413820275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8493420257810053635.post-5027758173539425208</id><published>2010-09-17T10:53:00.000-07:00</published><updated>2010-09-17T10:59:24.425-07:00</updated><title type='text'>jQuery Twitter plugin update</title><content type='html'>&lt;div class=&quot;post-header-line-1&quot;&gt;&lt;/div&gt;&lt;div class=&quot;post-body entry-content&quot;&gt;&lt;p&gt;A lot of users requested a demo for my &lt;a href=&quot;http://jquery-4u.blogspot.com/2009/04/jquery-twitter-api-plugin.html&quot; title=&quot;jQuery Tweeter plugin&quot;&gt;jQuery Twitter plugin&lt;/a&gt;. It has been a while since I updated the plugin, so I downloaded the latest version and while looking thought the code found couple of bugs. So, here comes updated and fixed jQuery Tweeter plugin - &lt;a rel=&quot;nofollow&quot; href=&quot;http://plugins.jquery.com/project/jtwitter&quot;&gt;jTwitter 1.1.1&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;In this release, I fixed a little bug that would not allow you request Tweets without number of posts like this:&lt;/p&gt;  &lt;pre class=&quot;prettyprint lang-js&quot;&gt;&lt;span class=&quot;com&quot;&gt;// Defaults to 5 latest posts&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;$&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;jTwitter&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;jQueryHowto&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;posts&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;//Callback function with the user data&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;});&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;You can specify the number of posts you want to be fetched like so:&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;prettyprint lang-js&quot;&gt;&lt;span class=&quot;com&quot;&gt;// Get latest 13 posts&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;$&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;jTwitter&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&#39;jQueryHowto&#39;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;posts&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span class=&quot;com&quot;&gt;//Callback function with the user data&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;});&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Also, I created a simple &lt;strong&gt;demo page&lt;/strong&gt; for the plugin &lt;a href=&quot;http://custom-drupal.com/jquery-demo/jtwitter/&quot; title=&quot;jQuery Tweeter plugin demo page&quot;&gt;here&lt;/a&gt;. Please visit and see the code and also note that with this plugin you can create a custom Twitter badge with no design limitations!&lt;/p&gt;&lt;blockquote&gt;&lt;strong&gt;Update:&lt;/strong&gt; Pushed the project to &lt;a rel=&quot;nofollow&quot; href=&quot;http://github.com/uzbekjon/jTwitter&quot;&gt;GitHub&lt;/a&gt;.&lt;/blockquote&gt;  &lt;/div&gt;&lt;div class=&quot;post-footer&quot;&gt;&lt;div class=&quot;post-footer-line post-footer-line-1&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;post-footer-line post-footer-line-2&quot;&gt;&lt;span class=&quot;post-labels&quot;&gt;Labels:&lt;br /&gt;&lt;a rel=&quot;tag&quot; href=&quot;http://jquery-4u.blogspot.com/search/label/jquery&quot;&gt;jquery&lt;/a&gt;,&lt;br /&gt;&lt;a rel=&quot;tag&quot; href=&quot;http://jquery-4u.blogspot.com/search/label/link&quot;&gt;link&lt;/a&gt;,&lt;br /&gt;&lt;a rel=&quot;tag&quot; href=&quot;http://jquery-4u.blogspot.com/search/label/news&quot;&gt;news&lt;/a&gt;,&lt;br /&gt;&lt;a rel=&quot;tag&quot; href=&quot;http://jquery-4u.blogspot.com/search/label/plugin&quot;&gt;plugin&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;post-footer-line post-footer-line-3&quot;&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jquery-4u.blogspot.com/feeds/5027758173539425208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/jquery-twitter-plugin-update.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/5027758173539425208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/5027758173539425208'/><link rel='alternate' type='text/html' href='http://jquery-4u.blogspot.com/2010/09/jquery-twitter-plugin-update.html' title='jQuery Twitter plugin update'/><author><name>gouse</name><uri>http://www.blogger.com/profile/13059729325413820275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8493420257810053635.post-4363331726685365196</id><published>2010-01-24T09:18:00.000-08:00</published><updated>2010-09-17T11:31:47.637-07:00</updated><title type='text'>Loading content with jQuery AJAX - using a loading image</title><content type='html'>Loading content with jQuery AJAX - using a loading image&lt;span style=&quot;font-weight:bold;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The .load() function doesn&#39;t have any way of dealing with errors in the examples provided here, so if the content is never loaded then the loading image will continue to display. I will show how to allow for error handling in a future post.&lt;br /&gt;&lt;br /&gt;I get my loading images from www.ajaxload.info which is a useful resource for generating animated GIF images suitable for showing content is loading. There are a number of different indicator images and you can change the foreground and background colours.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Example in action&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Click the &quot;Click Me!&quot; button below to see a working example in action. If you are viewing this in an RSS reader then you&#39;ll need to click through to the post in a web browser for the example to work.&lt;br /&gt;&lt;br /&gt;After clicking &quot;Click Me!&quot; the loading image will appear, then the AJAX request will be made. The content from the AJAX request will replace the loading image once it has been loaded. For the purposes of this example, there&#39;s a 2 second delay between the loading image displaying and the AJAX request being made. See my &quot;Using setTimeout() with Javascript&quot; post for details about how to make a function run after a set time.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;How it works&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The HTML for the above example looks like this:&lt;br /&gt;&lt;br /&gt;&amp;lt;input type=&quot;button&quot; onclick=&quot;example_ajax_request()&quot; value=&quot;Click Me!&quot; /&amp;gt;&lt;br /&gt;&amp;lt;div id=&quot;example-placeholder&quot;&amp;gt;&lt;br /&gt; &amp;lt;p&amp;gt;Placeholding text&amp;lt;/p&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;br /&gt;function example_ajax_request() {&lt;br /&gt; $(&#39;#example-placeholder&#39;).html(&#39;&amp;lt;p&amp;gt;&amp;lt;img src=&quot;/images/ajax-loader.gif&quot; width=&quot;220&quot; height=&quot;19&quot; /&amp;gt;&amp;lt;/p&amp;gt;&#39;);&lt;br /&gt; $(&#39;#example-placeholder&#39;).load(&quot;/examples/ajax-loaded.html&quot;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The first line in the example_ajax_request() function sets the html of the &lt;div&gt; to the loading image, and the second line then loads the content from /examples/ajax-loaded.html into the div.&lt;br /&gt;&lt;br /&gt;It&#39;s best in this sort of situation to pre-load the loading image so that when the button is clicked it appears immediately from the cache. If this is not done then the AJAX request may be completed before the image has finished downloading. I&#39;ll look at doing that in another post.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jquery-4u.blogspot.com/feeds/4363331726685365196/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jquery-4u.blogspot.com/2010/01/loading-content-with-jquery-ajax-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/4363331726685365196'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/4363331726685365196'/><link rel='alternate' type='text/html' href='http://jquery-4u.blogspot.com/2010/01/loading-content-with-jquery-ajax-using.html' title='Loading content with jQuery AJAX - using a loading image'/><author><name>gouse</name><uri>http://www.blogger.com/profile/13059729325413820275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8493420257810053635.post-2931815488570273398</id><published>2009-07-08T10:17:00.000-07:00</published><updated>2009-07-08T10:19:48.432-07:00</updated><title type='text'>How do I ... ?</title><content type='html'>&lt;span style=&quot;font-weight:bold;&quot;&gt;How do I select an item using class or id? &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;    *  This code selects an element with an id of &quot;myDivId&quot;. Since id&#39;s are unique this expression always selects 1 element, or none if the id does not exist. &lt;br /&gt;&lt;br /&gt;  $(&#39;#myDivId&#39;)&lt;br /&gt;&lt;br /&gt;    * This code selects an element with a class of &quot;myCssClass&quot;. Since any number of elements can have the same class, this expression will select any number of elements. &lt;br /&gt;&lt;br /&gt;  $(&#39;.myCssClass&#39;)&lt;br /&gt;&lt;br /&gt;A selected element can be assigned to a javascript variable like this&lt;br /&gt;&lt;br /&gt;  var myDivElement = $(&#39;#myDivId&#39;);&lt;br /&gt;&lt;br /&gt;Usually selected elements are acted on by other JQuery functions:&lt;br /&gt;&lt;br /&gt;  var myValue = $(&#39;#myDivId&#39;).val();    // get the value of an element&lt;br /&gt;&lt;br /&gt;  $(&#39;#myDivId&#39;).val(&quot;hello world&quot;);     // set the value of an element</content><link rel='replies' type='application/atom+xml' href='http://jquery-4u.blogspot.com/feeds/2931815488570273398/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jquery-4u.blogspot.com/2009/07/how-do-i.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/2931815488570273398'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/2931815488570273398'/><link rel='alternate' type='text/html' href='http://jquery-4u.blogspot.com/2009/07/how-do-i.html' title='How do I ... ?'/><author><name>gouse</name><uri>http://www.blogger.com/profile/13059729325413820275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8493420257810053635.post-3687064179062314274</id><published>2009-05-15T11:40:00.000-07:00</published><updated>2009-05-15T12:39:55.968-07:00</updated><title type='text'>How to use JQuery</title><content type='html'>&lt;h4 style=&quot;font-family: verdana;&quot;&gt;Jquery is JavaScript Library&lt;/h4&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;It is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;jQuery is designed to change the way that you write JavaScript.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;How to use JQuery ?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;To use JQuery we need to add below code&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt; &lt;/span&gt;&lt;code style=&quot;font-family: verdana;&quot;&gt;script&lt;/code&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;  type=&quot;text/javascript&quot; src=&quot;jquery.js&quot;&gt; &lt; /script &gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;But remember if jquery.js is in the same directory as your HTML file, then give give the above path.I will suggest to make javascript in separate directory, like &quot;/_js&quot; folder , In that folder you can include your update version jquery.js and your own JS file which you use in your site like &quot;global.js&quot;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;So path can be :&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt; &lt;/span&gt;&lt;code style=&quot;font-family: verdana;&quot;&gt;script&lt;/code&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;  type=&quot;text/javascript&quot; src=&quot;_js/jquery.js&quot;&gt; &lt; /script &gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt; &lt;/span&gt;&lt;code style=&quot;font-family: verdana;&quot;&gt;script&lt;/code&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;  type=&quot;text/javascript&quot; src=&quot;_js/global.js&quot;&gt; &lt; /script &gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;You can download your new version of jQuery.js from the &lt;/span&gt;&lt;a style=&quot;font-family: verdana;&quot; href=&quot;http://docs.jquery.com/Downloading_jQuery&quot;&gt;Jquery.com&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;jQuery has a simple statement that checks the document and waits until it&#39;s ready to be manipulated, known as the &lt;a style=&quot;font-family: verdana;&quot; href=&quot;http://docs.jquery.com/Events#ready.28_fn_.29&quot; title=&quot;Events&quot;&gt;ready event&lt;/a&gt; &lt;pre style=&quot;font-family: verdana;&quot;&gt; $(document).ready(function(){&lt;br /&gt;// Your code here&lt;br /&gt;});&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Example :&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;p style=&quot;font-family: verdana;&quot;&gt;Inside the ready event, I have added click handler to the link: &lt;/p&gt;&lt;code class=&quot;javascript&quot;&gt;&lt;br /&gt;$(document).ready(function(){&lt;br /&gt;$(&quot;a&quot;).click(function(event){&lt;br /&gt;alert(&quot;It is easy......&quot;);&lt;br /&gt;});&lt;br /&gt;});&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;If you want the convenience of the &lt;code style=&quot;font-weight: bold;&quot;&gt;$&lt;/code&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt; function&lt;/span&gt; for jQuery &lt;span style=&quot;font-weight: bold;&quot;&gt;without colliding&lt;/span&gt;&lt;br /&gt;some other use of the global &lt;code&gt;$&lt;/code&gt; function,the jQuery documentation suggests the&lt;br /&gt;following &lt;code class=&quot;javascript&quot;&gt;:&lt;br /&gt;&lt;br /&gt;(function($) {&lt;br /&gt;// Within this block, $ is a reference to jQuery&lt;br /&gt;});&lt;/code&gt;</content><link rel='replies' type='application/atom+xml' href='http://jquery-4u.blogspot.com/feeds/3687064179062314274/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://jquery-4u.blogspot.com/2009/05/how-to-use-jquery.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/3687064179062314274'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8493420257810053635/posts/default/3687064179062314274'/><link rel='alternate' type='text/html' href='http://jquery-4u.blogspot.com/2009/05/how-to-use-jquery.html' title='How to use JQuery'/><author><name>gouse</name><uri>http://www.blogger.com/profile/13059729325413820275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>