这样可行,但在通话过程中会冻结页面:
getAllNewEstate: function(callback) {
function NewEstateData() {};
var items = Backendless.Persistence.of( NewEstateData ).find().data;
callback(items)
},
如何进行异步通话?
文档: http://backendless.com/documentation/data/js/data_sync_and_async_calls.htm http://backendless.com/documentation/data/js/data_basic_search.htm
更新
我试过了:
getAllNewEstate: function(callback) {
function NewEstateData() {};
Backendless.Persistence.of( NewEstateData ).find( function(e) {
console.log('event', e);
callback(e.data);
});
},
//没有错误,没有console.log,
getAllNewEstate: function(callback) {
Backendless.Persistence.of( NewEstateData ).find( function(e) {
console.log('event', e);
callback(e.data);
});
},
//未捕获的ReferenceError:未定义NewEstateData
答案 0 :(得分:1)
您需要为异步调用查找添加回调:
getAllNewEstate: function(callback) {
function NewEstateData() {};
Backendless.Persistence.of( NewEstateData ).find( new Backendless.Async(
function(e) {
console.log(e);
callback(e);
})
);
}