Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The code below should help you. What I've done is moved the code which fetches the tweets into a function. This function is then called every X seconds to update the box. When the user enters a new search term and clicks "Enter", it will reset the timer.</p> <pre><code>var fetchSeconds = 30; //Number of seconds between each update var timeout; //The variable which holds the timeout $(document).ready(function() { $("#Enter").click(function(event){ //Clear old timeout clearTimeout(timeout); //Fetch initial tweets fetchTweets(); }); }); function fetchTweets() { //Setup to fetch every X seconds timeout = setTimeout('fetchTweets()',(fetchSeconds * 1000)); var searchTerm = $("#search").val(); var baseUrl = "http://search.twitter.com/search.json?q=%23"; $.getJSON(baseUrl + searchTerm + "&amp;rpp=1500&amp;callback=?", function(data) { $("#tweets").empty(); if (data.results.length &lt; 1) { $('#tweets').html("No results JOINEVENTUS"); } $.each(data.results, function() { $('&lt;div align="justify"&gt;&lt;/div&gt;').hide() .append('&lt;hr&gt; &lt;img src="' + this.profile_image_url + '" width="40px" /&gt; ') .append('&lt;span&gt;&lt;a href="http://www.twitter.com/'+ this.from_user + '"&gt;' + this.from_user + '&lt;/a&gt; ' + makeLink(this.text) + '&lt;/span&gt;') .appendTo('#tweets') .fadeIn(800); }); }); } function makeLink(text) { var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&amp;@#\/%?=~_|!:,.;]*[-A-Z0-9+&amp;@#\/%=~_|])/ig; return text.replace(exp,"&lt;a href='$1'&gt;$1&lt;/a&gt;"); } </code></pre> <p>Hope this helps</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.
 

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