<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="https://mg.to" xmlns:dc="https://purl.org/dc/elements/1.1/">
<channel>
 <title>mg.to - JSON for jQuery - Comments</title>
 <link>https://mg.to/2006/01/25/json-for-jquery</link>
 <description>Comments for &quot;JSON for jQuery&quot;</description>
 <language>en</language>
<item>
 <title>ABOUT JQUERY WITH</title>
 <link>https://mg.to/2006/01/25/json-for-jquery#comment-6177</link>
 <description>&lt;p&gt;ABOUT JQUERY WITH JSON&lt;br /&gt;
please give me suggation&lt;/p&gt;

&lt;p&gt;WITH COMPLETE EXAMPLE&lt;/p&gt;</description>
 <pubDate>Thu, 18 Mar 2010 05:37:08 +0000</pubDate>
 <dc:creator>bhagwat sharma</dc:creator>
 <guid isPermaLink="false">comment 6177 at https://mg.to</guid>
</item>
<item>
 <title>RSS &amp; JSON</title>
 <link>https://mg.to/2006/01/25/json-for-jquery#comment-6161</link>
 <description>&lt;p&gt;I would also recommend lightweight syntex highlighter called &amp;#8220;prettyprint&amp;#8221; used on Google Code. It is lightweight and looks very clean.&lt;/p&gt;

&lt;p&gt;Regarding this post. I came across it while searching for &lt;a href=&quot;https://jquery-howto.blogspot.com/2009/11/cross-domain-rss-to-json-converter.html&quot;&gt;RSS to JSON converter&lt;/a&gt; plugin for jQuery. I thought I would share it here with everybody. The great thing about it is that you don&amp;#8217;t need to setup any server-side scripts. All you need is a jQuery.js file. Everything is done on client side leveraging Google Feeds API.&lt;/p&gt;

&lt;p&gt;Here is an example from original post:&lt;/p&gt;

&lt;div style=&quot;padding: 5px !important; border: 1px solid rgb(253,187,134) !important; background-color: rgb(255,253,245) !important; font-family: Verdana,sans-serif !important;&quot;&gt;&lt;div style=&quot;background-color: rgb(255,250,238) !important;&quot;&gt;&lt;div&gt;&amp;lt;script src=&amp;quot;jquery.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;jquery.jgfeed.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
$.jGFeed(&#039;https://twitter.com/statuses/user_timeline/26767000.rss&#039;,&lt;br /&gt;
&amp;nbsp; function(feeds){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; // Check for errors&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(!feeds){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; // there was an error&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; return false;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; // do whatever you want with feeds here&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(var i=0; i&amp;lt;feeds.entries.length; i++){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; var entry = feeds.entries[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; // Entry title&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; entry.title;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; }, 10);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 10 Nov 2009 05:38:29 +0000</pubDate>
 <dc:creator>jQuery Convert</dc:creator>
 <guid isPermaLink="false">comment 6161 at https://mg.to</guid>
</item>
<item>
 <title>Maybe in the core now, but...</title>
 <link>https://mg.to/2006/01/25/json-for-jquery#comment-6134</link>
 <description>&lt;p&gt;&amp;#8230; the core implementation have some serious limitations.&lt;/p&gt;

&lt;p&gt;I made &lt;a href=&quot;https://code.google.com/p/jquery-jsonp/&quot;&gt;jquery-jsonp&lt;/a&gt; to deal with them.&lt;/p&gt;</description>
 <pubDate>Sat, 28 Mar 2009 13:18:29 +0000</pubDate>
 <dc:creator>Julian</dc:creator>
 <guid isPermaLink="false">comment 6134 at https://mg.to</guid>
</item>
<item>
 <title>Autopulate select dropdown using jquery and json</title>
 <link>https://mg.to/2006/01/25/json-for-jquery#comment-6092</link>
 <description>&lt;p&gt;Hello&lt;/p&gt;

&lt;p&gt;I need your help on this.&lt;/p&gt;

&lt;p&gt;Example:
I have JSON data &lt;/p&gt;

&lt;p&gt;Country Code&lt;/p&gt;

&lt;p&gt;Belgium 106
China 103&lt;/p&gt;

&lt;p&gt;How do I populate a HTML select dropdown box with the json data&lt;/p&gt;

&lt;p&gt;Select Dropdown(Belgium, China)&lt;/p&gt;

&lt;p&gt;Now when I select a value like China, it should traverse JSON and display the code.&lt;/p&gt;

&lt;p&gt;Can someone show me an example of how, this can be done using JSON and Jquery.&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;</description>
 <pubDate>Mon, 29 Sep 2008 02:52:36 +0000</pubDate>
 <dc:creator>Visitor</dc:creator>
 <guid isPermaLink="false">comment 6092 at https://mg.to</guid>
</item>
<item>
 <title>JSONP now in jQuery 1.2 core</title>
 <link>https://mg.to/2006/01/25/json-for-jquery#comment-5226</link>
 <description>&lt;p&gt;Thanks for the kind words and the heads-up, Paul.&lt;/p&gt;

&lt;p&gt;As you probably know, the &lt;a href=&quot;https://docs.jquery.com/Release:jQuery_1.2&quot;&gt;jQuery 1.2&lt;/a&gt; core now &lt;a href=&quot;https://docs.jquery.com/Release:jQuery_1.2/Ajax#Cross-Domain_getJSON_.28using_JSONP.29&quot;&gt;supports cross-domain JSONP&lt;/a&gt; downloads natively. So there&amp;#8217;s probably not much need for the plugin any more. I haven&amp;#8217;t tested the new code yet, but it probably does a fine job.&lt;/p&gt;</description>
 <pubDate>Fri, 14 Sep 2007 04:07:06 +0000</pubDate>
 <dc:creator>Michael Geary</dc:creator>
 <guid isPermaLink="false">comment 5226 at https://mg.to</guid>
</item>
<item>
 <title>jQuery 1.1.4 and appending script elements</title>
 <link>https://mg.to/2006/01/25/json-for-jquery#comment-5161</link>
 <description>&lt;p&gt;Hi Michael,&lt;/p&gt;

&lt;p&gt;Excellent plugin first off. I love your closure solution for queuing the callbacks. I&amp;#8217;ve actually used the idea of it for a recent &lt;a href=&quot;https://jqueryjs.googlecode.com/svn/trunk/plugins/delicious/demo.html&quot;&gt;plugin to use the Del.icio.us json feeds&lt;/a&gt;. I had to modify it to use an auto-incrementing array to house the callback references instead of the date-string based hash object due to the need to call several scripts in rapid succession. I was seeing callbacks overwritten due to them getting the exact same date string (I was surprised).&lt;/p&gt;

&lt;p&gt;In any case&amp;#8230; The main reason for my comment is to point out a problem I just fixed in &lt;a href=&quot;https://jqueryjs.googlecode.com/svn/trunk/plugins/delicious/demo.html&quot;&gt;my plugin&lt;/a&gt; and which your code appears to share. jQuery 1.1.4 now detects script elements being appended to the DOM using the &lt;code&gt;$().append()&lt;/code&gt; method. When it detects one that also has a src attribute, it attempts to use $.ajax to grab the script and execute it. Our code will, for obvious reasons, cause that ajax call to fail. I had to go back to using real DOM methods to get it done. So, your 3rd to last line should be changed&amp;#8230;&lt;/p&gt;

&lt;div style=&quot;padding: 5px !important; border: 1px solid rgb(253,187,134) !important; background-color: rgb(255,253,245) !important; font-family: Verdana,sans-serif !important;&quot;&gt;&lt;div style=&quot;background-color: rgb(255,250,238) !important;&quot;&gt;&lt;div class=&quot;geshi-javascript&quot;&gt;&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// From this&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
$&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;head&#039;&lt;/span&gt;,document&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; script &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// To this&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
document.&lt;span style=&quot;color: #006600;&quot;&gt;getElementsByTagName&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;head&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;appendChild&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; script &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Thanks again for the great plugin.&lt;/p&gt;</description>
 <pubDate>Mon, 27 Aug 2007 21:23:31 +0000</pubDate>
 <dc:creator>Paul McLanahan</dc:creator>
 <guid isPermaLink="false">comment 5161 at https://mg.to</guid>
</item>
<item>
 <title>Cross-domain restriction</title>
 <link>https://mg.to/2006/01/25/json-for-jquery#comment-5121</link>
 <description>&lt;p&gt;Matthew, it sounds like you are running into cross-domain security. If your page is loaded from a domain other than &amp;#8220;sub.domain.tld&amp;#8221; then &lt;code&gt;$.ajax&lt;/code&gt; will fail.&lt;/p&gt;

&lt;p&gt;That is the whole point of the JSONP format with dynamic script tags as used in this plugin&amp;#8212;it avoids all of the cross-domain security issues. You can load a script tag from any domain, and JSONP format is simply a way to request that a specific callback function name be executed with the JSON data as an argument.&lt;/p&gt;

&lt;p&gt;Does your server actually provide JSONP output, where you can specify the callback function name in the URL? If it does, then you can use the plugin directly and not use &lt;code&gt;$.ajax&lt;/code&gt; at all.&lt;/p&gt;

&lt;p&gt;Tell me a bit more and we can come up with a solution&amp;#8230;&lt;/p&gt;</description>
 <pubDate>Fri, 24 Aug 2007 06:14:03 +0000</pubDate>
 <dc:creator>Michael Geary</dc:creator>
 <guid isPermaLink="false">comment 5121 at https://mg.to</guid>
</item>
<item>
 <title>JSONP with JQuery  $.ajax?</title>
 <link>https://mg.to/2006/01/25/json-for-jquery#comment-5115</link>
 <description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;Is there a way to use the jquery $.ajax along with your plug-in and get a JSONP object?&lt;/p&gt;

&lt;p&gt;Below is the code I have, but it&amp;#8217;s getting a &amp;#8220;XMLHttpRequest&amp;#8221; error because I&amp;#8217;m trying to call a resource from a sub-domain.&lt;/p&gt;

&lt;div style=&quot;padding: 5px !important; border: 1px solid rgb(253,187,134) !important; background-color: rgb(255,253,245) !important; font-family: Verdana,sans-serif !important;&quot;&gt;&lt;div style=&quot;background-color: rgb(255,250,238) !important;&quot;&gt;&lt;div class=&quot;geshi-javascript&quot;&gt;&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// initial ajax setup&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
$.&lt;span style=&quot;color: #006600;&quot;&gt;ajaxSetup&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; type: &lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;GET&quot;&lt;/span&gt;,&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; dataType: &lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;json&quot;&lt;/span&gt;,&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; global: &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;true&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; url: &lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;https://sub.domain.tld/data&quot;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// offers ajax call&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
$.&lt;span style=&quot;color: #006600;&quot;&gt;ajax&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; data: &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;page: &lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;offers&quot;&lt;/span&gt;, response: &lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;jsonp&quot;&lt;/span&gt;, limit: &lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;10&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;,&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; success: handleOffersSuccess,&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; error: handleOffersError&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// success funciton&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; handleOffersSuccess&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;obj&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; objCnt = obj.&lt;span style=&quot;color: #006600;&quot;&gt;offers&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;length&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;$&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;#ajax-offers&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #C00000;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; i=&lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;; i&amp;lt;objCnt; i++&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; advertiser = obj.&lt;span style=&quot;color: #006600;&quot;&gt;offers&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;advertiser&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; subject = obj.&lt;span style=&quot;color: #006600;&quot;&gt;offers&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;subject&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; url = obj.&lt;span style=&quot;color: #006600;&quot;&gt;offers&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;url&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; image_url = obj.&lt;span style=&quot;color: #006600;&quot;&gt;offers&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;image_url&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #C00000;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; url == &lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&quot;&lt;/span&gt; || url == &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;null&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; advertiser = EscapeChar&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;advertiser&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; subject = EscapeChar&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;subject&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #C00000;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;i==&lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;#ajax-offers&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;lt;dt&amp;gt;&quot;&lt;/span&gt;+advertiser+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&amp;lt;/dt&amp;gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;lt;dd&amp;gt;&quot;&lt;/span&gt;+subject+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&amp;lt;/dd&amp;gt;&amp;lt;dd&amp;gt;&amp;lt;img src=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&quot;&lt;/span&gt;+image_url+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&amp;gt;&amp;lt;/dd&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #C00000;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;#ajax-offers&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;lt;dt&amp;gt;&quot;&lt;/span&gt;+advertiser+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&amp;lt;/dt&amp;gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;lt;dd&amp;gt;&quot;&lt;/span&gt;+subject+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&amp;lt;/dd&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// end first object test&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #C00000;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; advertiser = EscapeChar&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;advertiser&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; subject = EscapeChar&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;subject&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; url = EscapeChar&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;url&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; img = image_url.&lt;span style=&quot;color: #006600;&quot;&gt;length&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #C00000;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;i==&lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #C00000;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;img!=&lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;#ajax-offers&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;lt;dt&amp;gt;&amp;lt;a href=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&quot;&lt;/span&gt;+url+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt; title=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;Offer From &quot;&lt;/span&gt;+advertiser+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&amp;gt;&quot;&lt;/span&gt;+advertiser+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&amp;lt;/a&amp;gt;&amp;lt;/dt&amp;gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;lt;dd&amp;gt;&amp;lt;a href=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&quot;&lt;/span&gt;+url+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt; title=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;Offer From &quot;&lt;/span&gt;+advertiser+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;: &quot;&lt;/span&gt;+subject+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&amp;gt;&quot;&lt;/span&gt;+subject+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&amp;lt;/a&amp;gt;&amp;lt;/dd&amp;gt;&amp;lt;dd&amp;gt;&amp;lt;a href=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&quot;&lt;/span&gt;+url+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt; title=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;Offer From &quot;&lt;/span&gt;+advertiser+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;: &quot;&lt;/span&gt;+subject+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&amp;gt;&amp;lt;img src=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&quot;&lt;/span&gt;+image_url+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/dd&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #C00000;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;#ajax-offers&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;lt;dt&amp;gt;&amp;lt;a href=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&quot;&lt;/span&gt;+url+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt; title=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;Offer From &quot;&lt;/span&gt;+advertiser+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&amp;gt;&quot;&lt;/span&gt;+advertiser+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&amp;lt;/a&amp;gt;&amp;lt;/dt&amp;gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;lt;dd&amp;gt;&amp;lt;a href=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&quot;&lt;/span&gt;+url+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt; title=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;Offer From &quot;&lt;/span&gt;+advertiser+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;: &quot;&lt;/span&gt;+subject+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&amp;gt;&quot;&lt;/span&gt;+subject+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&amp;lt;/a&amp;gt;&amp;lt;/dd&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// end image test&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #C00000;&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;#ajax-offers&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;lt;dt&amp;gt;&amp;lt;a href=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&quot;&lt;/span&gt;+url+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt; title=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;Offer From &quot;&lt;/span&gt;+advertiser+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&amp;gt;&quot;&lt;/span&gt;+advertiser+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&amp;lt;/a&amp;gt;&amp;lt;/dt&amp;gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;lt;dd&amp;gt;&amp;lt;a href=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&quot;&lt;/span&gt;+url+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt; title=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;Offer From &quot;&lt;/span&gt;+advertiser+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;: &quot;&lt;/span&gt;+subject+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&quot;&lt;/span&gt;&amp;gt;&quot;&lt;/span&gt;+subject+&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&amp;lt;/a&amp;gt;&amp;lt;/dd&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// end first object test&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// end url test&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// end for loop&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// end offers success function&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// offers error funciton&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; handleOffersError&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;request,errtype,e&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;//alert(&#039;An error occurred while loading. Error Reported:\n&#039; + e.message + &#039;(&#039; + e.description + &#039;).&#039;);&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; $&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;#ajax-offers&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&quot;&amp;lt;p&amp;gt;I&#039;m sorry but there was an error retrieving the data.&amp;lt;/p&amp;gt;&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// end offers error function &lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Thu, 23 Aug 2007 16:43:00 +0000</pubDate>
 <dc:creator>Matthew Moore</dc:creator>
 <guid isPermaLink="false">comment 5115 at https://mg.to</guid>
</item>
<item>
 <title>All the plugin code you really need</title>
 <link>https://mg.to/2006/01/25/json-for-jquery#comment-5022</link>
 <description>&lt;p&gt;BTW, because of Flickr&amp;#8217;s hardcoded callback function name, the only part of the plugin that you&amp;#8217;re really using is the &lt;code&gt;load()&lt;/code&gt; function:&lt;/p&gt;

&lt;div style=&quot;padding: 5px !important; border: 1px solid rgb(253,187,134) !important; background-color: rgb(255,253,245) !important; font-family: Verdana,sans-serif !important;&quot;&gt;&lt;div style=&quot;background-color: rgb(255,250,238) !important;&quot;&gt;&lt;div class=&quot;geshi-javascript&quot;&gt;&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; load&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; url &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; script = document.&lt;span style=&quot;color: #006600;&quot;&gt;createElement&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;script&#039;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; script.&lt;span style=&quot;color: #006600;&quot;&gt;type&lt;/span&gt; = &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;text/javascript&#039;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; script.&lt;span style=&quot;color: #006600;&quot;&gt;src&lt;/span&gt; = url;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; $&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;head&#039;&lt;/span&gt;,document&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; script &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So you could omit the plugin entirely and use this code instead:&lt;/p&gt;

&lt;div style=&quot;padding: 5px !important; border: 1px solid rgb(253,187,134) !important; background-color: rgb(255,253,245) !important; font-family: Verdana,sans-serif !important;&quot;&gt;&lt;div style=&quot;background-color: rgb(255,250,238) !important;&quot;&gt;&lt;div class=&quot;geshi-javascript&quot;&gt;&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;$&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;document&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;ready&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; log&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;Document ready&#039;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; url = &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;https://api.flickr.com/services/feeds/photos_public.gne?ids=10861890@N04&amp;amp;format=json&#039;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; log&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;url:&#039;&lt;/span&gt;, url &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; loadJson&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; url &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; loadJson&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; url &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; script = document.&lt;span style=&quot;color: #006600;&quot;&gt;createElement&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;script&#039;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; script.&lt;span style=&quot;color: #006600;&quot;&gt;type&lt;/span&gt; = &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;text/javascript&#039;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; script.&lt;span style=&quot;color: #006600;&quot;&gt;src&lt;/span&gt; = url;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; $&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;head&#039;&lt;/span&gt;,document&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; script &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; jsonFlickrFeed&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; json &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; log&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;json feed received:&#039;&lt;/span&gt;, json &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Be sure to load your page with Firebug and watch the console log - it&amp;#8217;s pretty cool to see your name show up in the JSON response.&lt;/p&gt;

&lt;p&gt;Also, install the Firefox &lt;a href=&quot;https://chrispederick.com/work/web-developer/&quot;&gt;Web Developer toolbar&lt;/a&gt; if you don&amp;#8217;t already have it. Load your page and then select &lt;strong&gt;Information&lt;/strong&gt;/&lt;strong&gt;View JavaScript&lt;/strong&gt; from the toolbar. A new window or tab will open showing all of the scripts loaded in the page&amp;#8212;inline, .js files, and JSON downloads. Click the &lt;strong&gt;Collapse All&lt;/strong&gt; link at the top of the page to see just the URLs. Very handy to check out your JSON downloads this way.&lt;/p&gt;</description>
 <pubDate>Sun, 12 Aug 2007 18:46:00 +0000</pubDate>
 <dc:creator>Michael Geary</dc:creator>
 <guid isPermaLink="false">comment 5022 at https://mg.to</guid>
</item>
<item>
 <title>Thank  you</title>
 <link>https://mg.to/2006/01/25/json-for-jquery#comment-5016</link>
 <description>&lt;p&gt;Wow, all I have to say is THANK YOU. I really appreciate the time you took to help me understand this. I will be working on this today after I pick through your code you gave me. Thank you for teaching me the log(). &lt;/p&gt;</description>
 <pubDate>Sun, 12 Aug 2007 14:27:44 +0000</pubDate>
 <dc:creator>Eric</dc:creator>
 <guid isPermaLink="false">comment 5016 at https://mg.to</guid>
</item>
<item>
 <title>Working code</title>
 <link>https://mg.to/2006/01/25/json-for-jquery#comment-5010</link>
 <description>&lt;p&gt;Eric, you were pretty close there. Here&amp;#8217;s an updated version of your code that works:&lt;/p&gt;

&lt;div style=&quot;padding: 5px !important; border: 1px solid rgb(253,187,134) !important; background-color: rgb(255,253,245) !important; font-family: Verdana,sans-serif !important;&quot;&gt;&lt;div style=&quot;background-color: rgb(255,250,238) !important;&quot;&gt;&lt;div class=&quot;geshi-javascript&quot;&gt;&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; log&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #C00000;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; window.&lt;span style=&quot;color: #006600;&quot;&gt;console&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; console.&lt;span style=&quot;color: #006600;&quot;&gt;debug&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;apply&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; console, arguments &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #C00000;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000066;&quot;&gt;alert&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#93;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;join&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;apply&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; arguments, &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039; &#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;br /&gt;&lt;/div&gt;
$&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;document&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;ready&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; log&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;Document Ready&#039;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; url = &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;https://api.flickr.com/services/feeds/photos_public.gne?ids=10861890@N04&amp;amp;format=json&#039;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; log&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;url:&#039;&lt;/span&gt;, url &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; $&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;json&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; url &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; jsonFlickrFeed&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; json &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; log&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;json feed received:&#039;&lt;/span&gt;, json &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I added a &lt;code&gt;log()&lt;/code&gt; function to replace the alerts. If you load the page in Firefox with Firebug enabled, it will use &lt;code&gt;console.debug()&lt;/code&gt; to log the messages, including making objects like the &lt;code&gt;json&lt;/code&gt; response clickable and browsable. If Firebug is not available, it falls back to an &lt;code&gt;alert()&lt;/code&gt; call. The fancy &lt;code&gt;.apply()&lt;/code&gt; stuff is to make multiple arguments work in both these cases.&lt;/p&gt;

&lt;p&gt;There were two things wrong in the code. First, you need to call the &lt;code&gt;json&lt;/code&gt; function with &lt;code&gt;$(selector).json()&lt;/code&gt;, where &lt;code&gt;selector&lt;/code&gt; is an optional jQuery selector. You don&amp;#8217;t need any selector in this particular case, so I left it empty. (In hindsight, my requirement for &lt;code&gt;$()&lt;/code&gt; with or without the selector was a bit goofy&amp;#8212;I will probably update the code sometime to make it work the way you tried to use it.)&lt;/p&gt;

&lt;p&gt;After I fixed that, though, it still didn&amp;#8217;t get to the callback function with the &amp;#8220;json received&amp;#8221; message. So I tried opening your &lt;a href=&quot;https://api.flickr.com/services/feeds/photos_public.gne?ids=10861890@N04&amp;amp;format=json&amp;amp;jsonp=MikeTest&quot;&gt;Flickr feed URL&lt;/a&gt; directly in a browser, and found that the JSON response calls a function named &lt;code&gt;jsonFlickrFeed()&lt;/code&gt;. I changed the &lt;code&gt;{callback}&lt;/code&gt; to MikeTest, so the URL ended with &lt;code&gt;format=json&amp;amp;jsonp=MikeTest&lt;/code&gt;. I also tried changing it to &lt;code&gt;format=json&amp;amp;jsoncallback=MikeTest&lt;/code&gt; as described on Flickr&amp;#8217;s &lt;a href=&quot;https://www.flickr.com/services/api/response.json.html&quot;&gt;JSON API&lt;/a&gt; page, but the response still called &lt;code&gt;jsonFlickrFeed()&lt;/code&gt; instead of &lt;code&gt;MikeTest()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It appears that Flickr&amp;#8217;s &lt;a href=&quot;https://www.flickr.com/services/feeds/&quot;&gt;feed API&lt;/a&gt; doesn&amp;#8217;t support the user-defined callback function name that this plugin normally requres. (Their &lt;a href=&quot;https://www.flickr.com/services/api/&quot;&gt;REST API&lt;/a&gt; does support &lt;code&gt;jsoncallback=functionName&lt;/code&gt; and works fine with the plugin.)&lt;/p&gt;

&lt;p&gt;A quick workaround for that is to simply define the &lt;code&gt;jsonFlickrFeed()&lt;/code&gt; function directly instead of specifying the callback function in the &lt;code&gt;$().json()&lt;/code&gt; call. At this point the plugin isn&amp;#8217;t doing much for you except for creating the dynamic script tag, but it does get things working.&lt;/p&gt;

&lt;p&gt;When I get a chance I&amp;#8217;ll update the plugin to support this more directly. And hopefully Flickr will update their feed API to support the user-defined callback names as their REST API does.&lt;/p&gt;</description>
 <pubDate>Sun, 12 Aug 2007 09:14:36 +0000</pubDate>
 <dc:creator>Michael Geary</dc:creator>
 <guid isPermaLink="false">comment 5010 at https://mg.to</guid>
</item>
<item>
 <title>Link to test page?</title>
 <link>https://mg.to/2006/01/25/json-for-jquery#comment-5009</link>
 <description>&lt;p&gt;Eric, do you have a test page you could post a link to? Or else let me know what the JavaScript error was?&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ll try a test with your code, but if you have a link or error message that would give me a head start.&lt;/p&gt;</description>
 <pubDate>Sun, 12 Aug 2007 02:53:45 +0000</pubDate>
 <dc:creator>Michael Geary</dc:creator>
 <guid isPermaLink="false">comment 5009 at https://mg.to</guid>
</item>
<item>
 <title>json</title>
 <link>https://mg.to/2006/01/25/json-for-jquery#comment-5007</link>
 <description>&lt;p&gt;I added your code to my js files and put in the right order. I am new at this so I am trying to learn. When I runt he following code. I get an javascript error on my page and no output. Can you help me with what I am doing wrong. I am really trying to understand this stuff.  Thanks.&lt;/p&gt;

&lt;div style=&quot;padding: 5px !important; border: 1px solid rgb(253,187,134) !important; background-color: rgb(255,253,245) !important; font-family: Verdana,sans-serif !important;&quot;&gt;&lt;div style=&quot;background-color: rgb(255,250,238) !important;&quot;&gt;&lt;div class=&quot;geshi-javascript&quot;&gt;&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;$&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;document&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;ready&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000066;&quot;&gt;alert&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;Document Ready&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; url=&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;https://api.flickr.com/services/feeds/photos_public.gne?ids=10861890@N04&amp;amp;format=json&amp;amp;jsonp={callback}&#039;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000066;&quot;&gt;alert&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;url&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; $.&lt;span style=&quot;color: #006600;&quot;&gt;json&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;url,&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;json&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000066;&quot;&gt;alert&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;I received the json and put it in the json var : &#039;&lt;/span&gt; + json.&lt;span style=&quot;color: #006600;&quot;&gt;toString&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Sun, 12 Aug 2007 02:33:00 +0000</pubDate>
 <dc:creator>Eric</dc:creator>
 <guid isPermaLink="false">comment 5007 at https://mg.to</guid>
</item>
<item>
 <title>Thanks Michael.

I looked at</title>
 <link>https://mg.to/2006/01/25/json-for-jquery#comment-4944</link>
 <description>&lt;p&gt;Thanks Michael.&lt;/p&gt;

&lt;p&gt;I looked at the jQuery sources in the mean time. To me, jQuerys $.ajax seems to be lacking a fallback mechanism in case ActiveX controls are disabled. This is where your solution &amp;#8212; or Ralf Engelschalls &amp;#8212; could help.&lt;/p&gt;</description>
 <pubDate>Thu, 02 Aug 2007 21:46:36 +0000</pubDate>
 <dc:creator>Johann</dc:creator>
 <guid isPermaLink="false">comment 4944 at https://mg.to</guid>
</item>
<item>
 <title>They are different</title>
 <link>https://mg.to/2006/01/25/json-for-jquery#comment-4943</link>
 <description>&lt;p&gt;Both functions let you download JSON data, but they use different techniques and are made for different situations.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$.json()&lt;/code&gt; (this plugin) uses a dynamic script tag to download the JSON data. This lets it work across domains, but it requires that the JSON data be wrapped in a callback function (JSONP format).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$.getJSON()&lt;/code&gt; is an AJAX call, that is, it uses XMLHttpRequest. So it works only within the same domain&amp;#8212;you can&amp;#8217;t use it for cross-domain requests. But it doesn&amp;#8217;t require JSONP format; it will work with any standard JSON data.&lt;/p&gt;</description>
 <pubDate>Thu, 02 Aug 2007 19:05:00 +0000</pubDate>
 <dc:creator>Michael Geary</dc:creator>
 <guid isPermaLink="false">comment 4943 at https://mg.to</guid>
</item>
<item>
 <title>JSON for jQuery</title>
 <link>https://mg.to/2006/01/25/json-for-jquery</link>
 <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;Update 2007-09-13:&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;As of &lt;a href=&quot;https://docs.jquery.com/Release:jQuery_1.2&quot;&gt;version 1.2&lt;/a&gt;, the jQuery core now &lt;a href=&quot;https://docs.jquery.com/Release:jQuery_1.2/Ajax#Cross-Domain_getJSON_.28using_JSONP.29&quot;&gt;supports cross-domain JSONP downloads&lt;/a&gt; as part of the native Ajax support. I suggest you use this support instead of the plugin.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jquery.com/&quot; title=&quot;jQuery&quot;&gt;jQuery&lt;/a&gt; is a nifty new JavaScript library by &lt;a href=&quot;https://ejohn.org/&quot; title=&quot;John Resig&quot;&gt;John Resig&lt;/a&gt;. It features a &lt;a href=&quot;https://jquery.com/docs/base/&quot; title=&quot;$() function&quot;&gt;&lt;code&gt;$()&lt;/code&gt; function&lt;/a&gt; like the one in &lt;a href=&quot;https://prototype.conio.net/&quot; title=&quot;Prototype.js&quot;&gt;Prototype.js&lt;/a&gt;, but beefed up with &lt;a href=&quot;https://jquery.com/docs/CSS/&quot; title=&quot;CSS in jQuery&quot;&gt;CSS&lt;/a&gt; and &lt;a href=&quot;https://jquery.com/docs/XPath/&quot; title=&quot;XPath in jQuery&quot;&gt;XPath&lt;/a&gt; selectors, and with the ability to chain methods to do interesting things with concise code.&lt;/p&gt;

&lt;p&gt;Unlike Prototype, jQuery doesn&amp;#8217;t mess around with built-in JavaScript objects. It&amp;#8217;s new&amp;#8212;too new to have a version number!&amp;#8212;but I&amp;#8217;ve been writing some code with it and enjoying it.&lt;/p&gt;

&lt;p&gt;jQuery provides an easy way to write &lt;a href=&quot;https://jquery.com/docs/Plugin/&quot; title=&quot;jQuery plugins&quot;&gt;plugin methods&lt;/a&gt; to extend the &lt;code&gt;$&lt;/code&gt; function. For you &lt;a href=&quot;https://www.crockford.com/JSON/&quot; title=&quot;JSON&quot;&gt;JSON&lt;/a&gt; fans out there, here is a JSON plugin for jQuery which lets you write code like this:&lt;/p&gt;

&lt;div style=&quot;padding: 5px !important; border: 1px solid rgb(253,187,134) !important; background-color: rgb(255,253,245) !important; font-family: Verdana,sans-serif !important;&quot;&gt;&lt;div style=&quot;background-color: rgb(255,250,238) !important;&quot;&gt;&lt;div class=&quot;geshi-javascript&quot;&gt;&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; doJson&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; json &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// handle the json object here&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;$&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;#test&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;json&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;https://example.com/json-test?jsonp={callback}&#039;&lt;/span&gt;, doJson &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can of course use an anonymous function if you prefer:&lt;/p&gt;

&lt;div style=&quot;padding: 5px !important; border: 1px solid rgb(253,187,134) !important; background-color: rgb(255,253,245) !important; font-family: Verdana,sans-serif !important;&quot;&gt;&lt;div style=&quot;background-color: rgb(255,250,238) !important;&quot;&gt;&lt;div class=&quot;geshi-javascript&quot;&gt;&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; url = &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;https://example.com/json-test?jsonp={callback}&#039;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
$&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;#test&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;json&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; url, &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;json&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// handle the json object here&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Or, using jQuery&amp;#8217;s method chaining, you can combine calls like this code which displays a &amp;#8220;Loading&amp;#8230;&amp;#8221; message when it starts loading the JSON resource:&lt;/p&gt;

&lt;div style=&quot;padding: 5px !important; border: 1px solid rgb(253,187,134) !important; background-color: rgb(255,253,245) !important; font-family: Verdana,sans-serif !important;&quot;&gt;&lt;div style=&quot;background-color: rgb(255,250,238) !important;&quot;&gt;&lt;div class=&quot;geshi-javascript&quot;&gt;&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;$&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;#test&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;Loading...&#039;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;json&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;https://example.com/json-test?jsonp={callback}&#039;&lt;/span&gt;, doJson &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To install the plugin, simply paste this code into a .js file and load it after loading jquery.js:&lt;/p&gt;

&lt;div style=&quot;padding: 5px !important; border: 1px solid rgb(253,187,134) !important; background-color: rgb(255,253,245) !important; font-family: Verdana,sans-serif !important;&quot;&gt;&lt;div style=&quot;background-color: rgb(255,250,238) !important;&quot;&gt;&lt;div class=&quot;geshi-javascript&quot;&gt;&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// JSON for jQuery by Michael Geary&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// See https://mg.to/2006/01/25/json-for-jquery&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// Free beer and free speech. Enjoy!&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;$.&lt;span style=&quot;color: #006600;&quot;&gt;json&lt;/span&gt; = &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt; callbacks: &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;$.&lt;span style=&quot;color: #006600;&quot;&gt;fn&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;json&lt;/span&gt; = &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; url, callback &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; _$_ = &lt;span style=&quot;color: #C00000;&quot;&gt;this&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; load&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; url.&lt;span style=&quot;color: #006600;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0066FF;&quot;&gt;/&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;callback&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;/&lt;/span&gt;, &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;callback&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #C00000;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #C00000;&quot;&gt;this&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; callback &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; id = &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;new&lt;/span&gt; Date&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;getTime&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt; = &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;json_&#039;&lt;/span&gt; + id;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; cb = $.&lt;span style=&quot;color: #006600;&quot;&gt;json&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;callbacks&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#91;&lt;/span&gt;id&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#93;&lt;/span&gt; = &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; json &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #C00000;&quot;&gt;delete&lt;/span&gt; $.&lt;span style=&quot;color: #006600;&quot;&gt;json&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;callbacks&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#91;&lt;/span&gt;id&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #C00000;&quot;&gt;eval&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;delete &#039;&lt;/span&gt; + &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _$_.&lt;span style=&quot;color: #006600;&quot;&gt;each&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt; callback&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;json&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #C00000;&quot;&gt;eval&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt; + &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039; = cb&#039;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #C00000;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; load&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; url &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;var&lt;/span&gt; script = document.&lt;span style=&quot;color: #006600;&quot;&gt;createElement&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;script&#039;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; script.&lt;span style=&quot;color: #006600;&quot;&gt;type&lt;/span&gt; = &lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;text/javascript&#039;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; script.&lt;span style=&quot;color: #006600;&quot;&gt;src&lt;/span&gt; = url;&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;head&#039;&lt;/span&gt;,document&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#40;&lt;/span&gt; script &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;
&lt;div style=&quot;background-color:rgb(255,234,216);&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;color: #66cc66;color: #0000FF;&quot;&gt;&amp;#125;&lt;/span&gt;;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This adds a &lt;code&gt;json()&lt;/code&gt; method to the &lt;code&gt;$&lt;/code&gt; function. The first argument is the URL to the JSON resource, with the text &lt;code&gt;{callback}&lt;/code&gt; wherever the JSON callback method should be provided. In a &lt;a href=&quot;https://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/&quot; title=&quot;JSONP&quot;&gt;JSONP&lt;/a&gt; URL, you would use &lt;code&gt;jsonp={callback}&lt;/code&gt;; in a &lt;a href=&quot;https://developer.yahoo.net/common/json.html&quot; title=&quot;Yahoo! JSON&quot;&gt;Yahoo! JSON&lt;/a&gt; URL you would use &lt;code&gt;format=json&amp;amp;callback={callback}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The second argument is the callback function itself. When the JSON resource finishes loading, this function will be called with a single argument, the JSON object itself. Inside the callback function, &lt;code&gt;this&lt;/code&gt; is a reference to the &lt;a href=&quot;https://developer.mozilla.org/en/docs/DOM:element&quot; title=&quot;DOM element&quot;&gt;HTML element&lt;/a&gt; found by the &lt;code&gt;$&lt;/code&gt; function. (If &lt;code&gt;$&lt;/code&gt; found more than one element, the callback function is called for each of them.)&lt;/p&gt;

&lt;p&gt;The callback function is required, so this code won&amp;#8217;t work with plain JSON APIs like &lt;a href=&quot;https://del.icio.us/help/json&quot; title=&quot;del.icio.us JSON&quot;&gt;del.icio.us&lt;/a&gt; that don&amp;#8217;t let you specify a callback function. This would be easy enough to fix; I didn&amp;#8217;t need it for the code I was writing, and didn&amp;#8217;t think of it until just now. :-)&lt;/p&gt;

&lt;p&gt;The code goes to a bit of extra work to create both an array entry and a unique global name for each callback. The global name is what is substituted into the {callback} part of the URL. It uses this name instead of the array reference to ensure compatibility with any JSON APIs that don&amp;#8217;t allow special characters in the callback name. In fact, in the current code the &lt;code&gt;callbacks[]&lt;/code&gt; array entries are not really used, but I figured it could be handy to have an array of all outstanding callbacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; John Resig suggested a couple of improvements to the code, so it&amp;#8217;s updated, simpler and better now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update 2:&lt;/strong&gt; Code updated to include Stephen and Brent&amp;#8217;s fixes from the comments.&lt;/p&gt;
</description>
 <comments>https://mg.to/2006/01/25/json-for-jquery#comments</comments>
 <category domain="https://mg.to/topics/programming/javascript">JavaScript</category>
 <category domain="https://mg.to/topics/programming/javascript/jquery">jQuery</category>
 <category domain="https://mg.to/topics/programming/javascript/json">JSON</category>
 <pubDate>Wed, 25 Jan 2006 08:10:16 +0000</pubDate>
 <dc:creator>Michael Geary</dc:creator>
 <guid isPermaLink="false">122 at https://mg.to</guid>
</item>
</channel>
</rss>
