Note that there are some explanatory texts on larger screens.

plurals
  1. POFetching Twitter Feed with JSON and JQuery - Automatically Refresh?
    primarykey
    data
    text
    <p>I am working on a script which will "fetch" the latest tweets from the Twitter API, and then display them as HTML on my page using JQuery.</p> <p>I'm new to JQuery, so if someone could point me in the direction of the necessary function on the JQuery site I would be most grateful.</p> <p>I currently have built the following script:</p> <pre><code>&lt;!-- Use the Google jQuery CDN for lib support --&gt; &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt; &lt;!-- Setup and fetch the JSON data --&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ var url='http://search.twitter.com/search.json?callback=?&amp;q=@req'; $.getJSON(url,function(json){ &lt;!-- Iterate the file --&gt; $.each(json.results,function(i,tweet){ $("#results").append('&lt;p&gt;&lt;img src="'+tweet.profile_image_url+'" widt="48" height="48" /&gt;'+tweet.text+'&lt;/p&gt;'); $("#results").slideDown("slow"); }); }); }); &lt;/script&gt; &lt;!-- Output the file into the DIV --&gt; &lt;div id="results"&gt;&lt;/div&gt; </code></pre> <p>The script is working fine, however I would now like to incorporate some form of automatic refresh of the content. I.e "re-fetch" the feed every x minutes.</p> <p>From what I understand I need to replace .append with .html in order that the content is removed from the page before reload, however does anyone have any suggestions as to the best way of actually getting the content to refresh? I have found may articles expressing concerns over browser memory leaks etc, and don't want to head down the wrong path.</p> <p>I look forward to you responses, and thanks again.</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. 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