twitter search api with jquery error twitter search api with jquery error jquery jquery

twitter search api with jquery error


You need to write it a bit differently, like this:

$.getJSON("http://search.twitter.com/search.json?callback=?&q=stackoverflow",   function (r) {    console.log(r);});

To trigger JSONP it's looking for explicitly callback=?, which isn't in your named function version. To use the named callback, you're better off going with the $.ajax() full version:

$.ajax({  url: "http://search.twitter.com/search.json?q=stackoverflow",  dataType: "jsonp",  jsonpCallback: "myFunction"});function myFunction(r) { console.log(r); }


Just to add a bit more to the answer you can use the following code to display text within each returned tweet.

$.getJSON("http://search.twitter.com/search.json?callback=?&q=stackoverflow",function(data){for (i=0; i<data.results.length; i++){$("#tweets").append("<p><strong>Text: </strong>" + data.results[i].text + "<BR/>" + "<p><strong>Created at: </strong>" + data.results[i].created_at +"</p><br /><br />");}});

Then within your body html put the following div

<div id="tweets"></div>