我正在尝试将AJAX对象数据保存在变量中,以便将它们推送到我的Firebase中。
成功的AJAX请求后,我有这个功能:
success: function(brews){
//debugger
console.log(brews);
window.brewSearch1 = brews;
console.log(window.brewSearch1); // Saving the results objects
console.log(brews.data[0].name);
console.log(window.brewSearch1.data[0].name);
for (var i = 0; i < brews.data.length; i++){
console.log(brews.data[i].name);
window.beersByNames = brews.data[i].name;
window.beersByNamesWithDescriptions = brews.data[i].description;
console.log(window.beersByNames);
console.log(window.beersByNamesWithDescriptions);
//Store to Firebase
myDataRef.push({name: beersByNames_FB, text: brews.data[i].name});
myDataRef.push({name: beersByNamesWithDescriptions_FB, text: brews.data[i].description}); //Store Objects
}
},
我在将对象数据推入Firebase时遇到问题。
我应该使用myDataRef.push()。set({})吗?