javascript - Returned AJAX array not being copied to array -
I have a simple AJAX function that uses jQuery to return an array of 300 test objects from a database.
This data has been copied to a JS array. The code fragment looks like this:
Firebug says that Planets around. Long
is zero. Planet
Constructor looks like this:
function planet (x, y) {this.x = x; this. Y = y; }
I think this is a scoping issue, but I can not seem to find it. Creating a new object in other languages means that it exists on the heap and avoids the scope, but here it seems that disappears in ether.
How can I return an array and push it for use in my own array later (or in any other function)?
AJAX request happens asynchronously - you are not waiting for data before you Try and display
Move the display code to the callback and it should work.
Comments
Post a Comment