未捕获的错误invalid_state_err dom exception 11 phonegap

时间:2015-03-12 04:47:39

标签: javascript jquery exception dom phonegap-build

当我尝试执行代码(它在html页面中编写)时,我在此行上收到未被捕获的错误invalid_state_err dom exception 11 - >

tx.executeSql("UPDATE DETAILS SET username='"+item.doc.username+"' where id="+item.doc._id);

完整代码:

function init2(tx)
{
    var username = "abc";
    var password = "abc";

    $.ajax
    ({
        url: "http://10.6.121.55:4985/oms/_all_docs?include_docs=true",
        type: 'GET',
        contentType: 'application/json',
        mimeType: 'application/json',
        //dataType: 'jsonp',
        //  async: false,
        data: '{}',
        beforeSend: function (xhr){ 
            xhr.setRequestHeader('Authorization', make_base_auth(username, password)); 
        },
        complete: function(returnData) {

            alert(returnData); 
            alert(JSON.stringify(returnData));

            var syncData=JSON.stringify(returnData);
            ////////
            window.globalsyncedinData= $.parseJSON(syncData);
            alert("globalsyncedinData: "+window.globalsyncedinData);
            alert("globalsyncedinData_rows or syncData: "+window.globalsyncedinData.responseJSON.rows);
            var syncData= window.globalsyncedinData.responseJSON.rows;      
            /////

            $.each(syncData, function(i, item) {
                alert("Inside each ");
                //if(item.doc!=null)
                alert(item.doc.username);
                alert(item.doc._id);
                if(item.doc._id!="channelUsers"){      
                    alert("inside if");
                    tx.executeSql("UPDATE DETAILS SET username='"+item.doc.username+"' where id="+item.doc._id);
                    alert("username updated");
                    tx.executeSql("UPDATE DETAILS SET email='"+item.doc.email+"' where id="+item.doc._id);
                    alert("email updated");
                    tx.executeSql("UPDATE DETAILS SET mobile='"+item.doc.mobile+"' where id="+item.doc._id);
                    alert("mobile updated");

                    alert("SYNCED IN COMPLETE");
                }
            });
            //alert(data.total_rows);
            alert("all updation done");
        },
        error: function() {
            alert("ERROR in Authentication!");
            // localread();
        }
    });  
} 

FYI,

{"rows":[

{"key":"1424951086535","id":"1424951086535","value":{"rev":"1-6f7d2dca1cc0045ec4f2d7d2aadfc31c"},"doc":{"_id":"1424951086535","_rev":"1-6f7d2dca1cc0045ec4f2d7d2aadfc31c","acresowned":"6","email":"email@go.com","gender":"Male","homephone":"9999999999","mobile":"1111111111","username":"amitabh"}}

,{"key":"1425032119480","id":"1425032119480","value":{"rev":"1-7022963a7705226e775e3ed298088abf"},"doc":{"_id":"1425032119480","_rev":"1-7022963a7705226e775e3ed298088abf","acresowned":"7","email":"ram@gmail.com","gender":"Male","homephone":"9876551235","mobile":"7653788999","username":"ram"}}

,{"key":"1425373604840","id":"1425373604840","value":{"rev":"1-a3bd70dcdca631e9f9abb9d2b2180583"},"doc":{"_id":"1425373604840","_rev":"1-a3bd70dcdca631e9f9abb9d2b2180583","acresowned":"","email":"","gender":"Male","homephone":"","mobile":"","username":"abc"}}
],

"total_rows":3,"update_seq":10}

任何帮助都将非常感谢,因为我是这个平台的新手。 提前致谢! :)

1 个答案:

答案 0 :(得分:0)

我猜命令应该是tx.execSQL();不是tx.executeSQL();