views:

94

answers:

0

Hey!

I'm basically trying to get the existing code below to make a new ajax request every time it finishes so there would be a constant stream instead of it just stopping after a batch.

<script type="text/javascript">
$(document).ready(function(){
var twitterq = '';

function displayTweet(){
var i = 0;
var limit = $("#twitter-results > div").size();
var myInterval = window.setInterval(function () {
var element = $("#twitter-results div:last-child");
$("#twitter-results").prepend(element);
element.fadeIn("slow");
i++;
if(i==limit){
window.setTimeout(function () {
clearInterval(myInterval);
});
}
},2000);
}

$("form#twittersearch").submit(function() {
twitterq = $('#twitterq').attr('value');
$.ajax({
type: "POST",
url: "search.php",
cache: false,
data: "twitterq="+ twitterq,
success: function(html){
$("#twitter-results").html(html);
displayTweet();
}
});
return false;
});
});
</script>

The original code is located here - http://woork.blogspot.com/2009/07/twitter-api-how-to-create-stream-of.html the author did mention in one of his comments creating a constant stream but i just don't understand as i'm totally new to jquery and ajax.

call a new ajax request (to search.php) every time the current array with the search results is totally displayed in the page.

Then you have to confront the old array (first 20 results) with the new array (new 20 resutl). If there are new tweets in the second array display them, otherwise recall a new ajax request.

A simple way to confront two arrays is confronting the ID of tweets contained into these array

Thanks in advance!