Here's the code:
var newFeeds = []; // ** GLOBAL **
$(document.body).click(function() {
$.ajax({
type: "POST",
url: "http://mysite.com/feed.php",
success: function (data) {
$(newFeeds).push(data);
alert(newFeeds.length);
},
error: function(error){
alert('Error: ' + error);
},
dataType: "json"
});
});
I can get the data from the server. All is ok, but the array never fills up.
But strangely newFeeds.length
returns 0! Why?
I need to take the arrived data and push it into an array for later use.