我試圖將所有返回的對象存儲到一個對象供以後使用。我設置了循環,但是當我試圖用新對象執行一些代碼時,它是空的。在這種情況下,在這裏警告對象。我猜在循環完成之前警報正在執行。有任何解決這個問題的方法嗎?試圖將所有對象存儲到一個對象與解析和jQuery
var followers = new Array;
Parse.initialize("xxxxxx", "xxxxx");
var currentUser = Parse.User.current();
var users = JSON.stringify(currentUser);
var user = eval("(" + users + ")");
var listsfollow = user.Follow;
for (var i = 0; i < listsfollow.length; i++) {
var allUsers = Parse.Object.extend("User");
var query = new Parse.Query(allUsers);
query.get(listsfollow[i], {
success: function (results) {
followers.push(results);
},
error: function (object, error) {
// The object was not retrieved successfully.
// error is a Parse.Error with an error code and description.
}
});
};
alert(followers);
他不使用jquery ... – 2013-03-05 09:04:01