0

这有效,但它在调用期间冻结页面:

  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

4

1 回答 1

1

您需要为调用 find 异步添加回调:

getAllNewEstate: function(callback) {
    function NewEstateData() {};
    Backendless.Persistence.of( NewEstateData ).find( new Backendless.Async(
        function(e) {
             console.log(e);
             callback(e);
        })
    );
}
于 2015-07-04T07:49:03.547 回答