$.getJSON("http://graph.facebook.com/http://th.interscholarship.com/somkiat2013/1249?callback=?", function(data) { $.ajax({ type: "POST", url: "/update_social_stat.ajax.php", data: "do=updatefacebook&id=1249&stat=" + data.shares, success: function(msg) { } }); }); $.getJSON("http://urls.api.twitter.com/1/urls/count.json?url=http://th.interscholarship.com/somkiat2013/1249&callback=?", function(data) { $.ajax({ type: "POST", url: "/update_social_stat.ajax.php", data: "do=updatetwitter&id=1249&stat=" + data.count, success: function(msg) { } }); });