javascript - Printing the JSON data? -


i learning how use javascript wrote simple script prints out public facebook statuses particular keyword. reason, not doing expect do. sample url json found be: http://graph.facebook.com/search?q=beatles

right now, not printing results. can spot error in this?

<input type="text" id="query" /><button>add</button><br /> <div id="results">  </div>  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ var url='http://graph.facebook.com/search?q='; var query;     $('button').click(function(){         query=$("#query").val();         $.getjson(url+query,function(json){             $.each(json.data,function(i,feed){                  if(feed.type=='status') {                         $("#results").append('<p>'+feed.message+'</p>');                                   }             });         });     }); }); </script> 

you cannot retrieve data external url (same origin policy) . possible jsonp, facebook api supports. have add callback=? url in order use it:

var url='http://graph.facebook.com/search?callback=?&q='; 

(this done in twitter example linked in comment deleted answer)


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -