My attempt to use setInterval for sending an AJAX request every 2 seconds is causing the page to crash. It seems like there is something wrong in my code!
Check out the code below:
var fburl = "http://graph.facebook.com/http://xzenweb.co.uk?callback=?";
//fetching data from Facebook API
$.getJSON(fburl, function(data){
var name = data["shares"];
var dataString = 'shares=' + name;
//sending share count data to server
$.ajax({
type: "POST",
url: "index.php",
data: dataString,
cache: false,
success: function(html)
{
$("#content").html(html);
}
});
return false;
});
I'm new to ajax and javascript, any help would be greatly appreciated :)