HTML5 Database API : Synchronous request

后端 未结 3 587
一个人的身影
一个人的身影 2021-01-12 11:21

i currently use the client side database on an html5 iphone webapp. In my code i need to check if a row is present in the local DB :

function isStarted(oDB         


        
3条回答
  •  生来不讨喜
    2021-01-12 12:10

    You have to block the next execution when you intend to retrieve the results synchronously, The price you have to pay is the UI getting blocked during the execution.

    var ret = null;
    var finished = false;
    
    cfunction isStarted(oDB) {
             oDB.query(sql,params,function(transaction,result) {
                    ret = result;
                    finished = true;
             });
    
        while(!finished){
        ;//block next execution, while result is being fetched
        }
        return ret;
    }
    

提交回复
热议问题