I getting undefined using JSON in jQuery why?
Posted
by
YoniGeek
on Stack Overflow
See other posts from Stack Overflow
or by YoniGeek
Published on 2012-09-21T09:35:59Z
Indexed on
2012/09/21
9:37 UTC
Read the original article
Hit count: 221
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>
© Stack Overflow or respective owner