I getting undefined using JSON in jQuery why?
- by YoniGeek
Im learning some JSON, Im trying to list some data about dogs from twitter...but I can't really present the data...I believe that the error is inside map-method...something I'm missing...thanks for yr help
<body>
<h1>U almost there!!</h1>
<script src="jquery-1.7.1.js"> </script>
<script>
// PubSub
(function( $ ) {
var o = $( {} );
$.each({
trigger: 'publish',
on: 'subscribe',
off: 'unsubscribe'
}, function( key, val ) {
jQuery[val] = function() {
o[key].apply( o, arguments );
};
});
})( jQuery );
$.getJSON('http://search.twitter.com/search.json?q=dogs&callback=?', function( info) {
$.publish( 'twitter/info', info );
});
// ...
$.subscribe( 'twitter/info', function( e, info ) {
$('body').html(
$.map( info, function( obj) { // <--- here it's error, something Im missing right?
return '<li>' + obj.text + '</li>';
}).join('')
);
});
</script>
</body>
</html>