开发者

Synchronization problem in functions of Javascript

I am developing an application,In that application i have many functions that return us server data.. I have 40 function that needs to be executed 1 by 1 for synchronization to take place.SO i have taken a single function and placed my 40 functions in it... Now the problem is that some of these function skip performing database operations

My one out of 40 function to perform this is

function sync_down_client_info(){
    try {

            parent.parent.parent.stmt_select.text = "select query";
            parent.parent.parent.stmt_select.execute();
            parent.parent.parent.result = parent.parent.parent.stmt_select.getResult();
            if (parent.parent.parent.result.data != null) {
                    for (var i = 0; i < parent.parent.parent.result.data.length; i++) {

                            var admin_id = parent.parent.parent.admin_id;
                            var sync_client_date =  parent.parent.parent.result.data[i].last_sync_client;
   开发者_运维知识库                         // alert(admin_id+"======="+ sync_client_date);

                            GATEWAY = 'http://projects/one_acc/flashservices/gateway.php';
                            conn = new parent.parent.parent.air.NetConnection();
                            conn.connect(GATEWAY); 

            response = new parent.parent.parent.air.Responder(clientresult, clientFault);
                            conn.call('down_client_info', response,admin_id,sync_client_date);


                            response = new parent.parent.parent.air.Responder(clientserverdatetimeResult, clientserverdatetimeFault);
                            conn.call('check_datetime', response);

                    }
            };

and clientresult function is

function  clientresult(e)
     {

    for (var i=0; i<e.length; i++) {
            //alert(e.length);
            parent.parent.parent.stmt_select.text="select query ;
            parent.parent.parent.stmt_select.execute();
            parent.parent.parent.result = parent.parent.parent.stmt_select.getResult();
            if(parent.parent.parent.result.data!=null){


              parent.parent.parent.stmt_insert.text= "update client_info ;
                      parent.parent.parent.stmt_insert.execute();
            } 

can anyone tell me how to do this syncing?


jQuery has constructs like the AjaxQueue to avoid these race conditions you are seeing. I'd advise using these plugins.

Refer http://plugins.jquery.com/project/ajaxqueue

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜