Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // JavaScript Document
- jQuery(function(){
- // Execute this code when the page is ready to work
- // Create a Script Tag
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.src = "http://search.twitter.com/search.json?&q=%23life&callback=initialize&rpp=27&_="+ new Date().getTime();
- // Add the Script to the Body element, which will in turn load the script and run it.
- $("body").append(script);
- });
- function initialize(jsonData){
- var time = setInterval( function(){
- getNewTweets()
- }, 2000);
- processTheseTweets(jsonData);
- }
- function getNewTweets(){
- $.ajax({
- url: "http://search.twitter.com/search.json?&q=%23life&&callback=initialize&rpp=27&lang&result_type=recent&_="+ new Date().getTime(),
- dataType: 'jsonp',
- jsonpCallback: "processTheseTweets"
- });
- }
- function processTheseTweets(jsonData){
- x = 1;
- var shtml = '';
- var results = jsonData.results;
- if(results){
- // if there are results (it should be an array), loop through it with a jQuery function
- $.each(results, function(index,value){
- shtml += "<p class='content'><span class='author'>" + x + ". " + value.from_user + "</span>: " +
- value.text + "<span class='date'>" + value.created_at + "</span></p>";
- x = x+1;
- });
- // Load the HTML in the .tweet_stream div
- $(".tweet_stream").html( shtml );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment