I want to get a Twitter search with jQuery and pass it to a php script for formatting. I'm new to jQuery, so would love if someone could tell me if this hopelessly off?
This is my jQuery, which is supposed to call up Twitter, get the json, and then pass the json to php.
//jquery
$(document).ready(function() {
var twUrl = "http://search.twitter.com/search.json?q=twitter&rpp=5&callback=?";
$.jsonp({
url: twUrl,
data: {},
dataType: "jsonp",
callbackParameter: "callback",
timeout: 5000,
success: function(data){
$.post("search_back.php", {json_data: data},
function(data) { $("#search_word").html() });
}});
});
and the php is supposed to pick it up, format it (not included, but I know how to do that part), and pass it back into the #search_word.
//search_back.php
$output = json_decode($_POST["data"], true);
foreach ($output as $tweet){
echo $tweet;
}
Is this close? Really appreciate some help!