Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="https://stackoverflow.com/users/43452/stobor">Stobor</a> is on the right track. I visited the page with the class and how-to information that you obviously used: <a href="http://www.xml.com/pub/a/2005/12/21/json-dynamic-script-tag.html" rel="nofollow noreferrer">http://www.xml.com/pub/a/2005/12/21/json-dynamic-script-tag.html</a>. The script there takes advantage of the callback= value that Yahoo uses to specify the callback function that wraps the JSON data (thus making it JSON<b>P</b> data). You have a callback=getGeo in your URL, but the <a href="http://twittercounter.com/pages/api" rel="nofollow noreferrer">TwitterCounter API</a> does <b>NOT</b> have a way to specify a callback function. I created a full HTML page using the code you were using:</p> <pre><code> &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Twittercounter API Test&lt;/title&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="jsr_class.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var bObj; // Define the callback function function getGeo(jsonData) { $('#content').append(''+jsonData.rank+''); bObj.removeScriptTag(); } $(document).ready(function() { $('form#search').bind("submit", function(e){ e.preventDefault(); $('#content').html(''); // The web service call var req = 'http://twittercounter.com/api/?username=Anand_Dasgupta&amp;output=json&amp;results=3&amp;callback=getGeo'; // Create a new request object bObj = new JSONscriptRequest(req); // Build the dynamic script tag bObj.buildScriptTag(); // Add the script tag to the page bObj.addScriptTag(); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="search"&gt; &lt;input type="submit" id="search" value="Get Info" /&gt; &lt;/form&gt; &lt;div id="content"&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and Firebug gave me an error when I activated the button. The reason is based on this paragraph in the original article's writeup:</p> <blockquote> That's a valid JavaScript statement, so it can be the target of a script tag that returns JavaScript (raw JSON data, without the callback function, is not a valid JavaScript statement, so it will fail to load if it is the target of a script tag). For comparison, look at the XML version of this call here. </blockquote> <p>The "valid JavaScript statement" is the one with the function name wrapping the actual data.</p> <p>Stobor's solution would be perfect, if Twittercounter would allow for JSONP requests and let you specify a wrapper function. As it is, you'll have to create your own proxy to act as an intermediary. I have an example on <a href="http://www.carolinamantis.com/wordpress/?p=29" rel="nofollow noreferrer">how to create one using PHP on my blog</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload