Web应用程序SQLite插件在Chrome 11中运行良好,自版本12以来就失败了。

时间:2011-09-26 04:51:15

标签: sqlite google-chrome

我在具有离线功能的网络应用程序中有一个javascript / jquery功能,可以在Chrome 11中运行良好,但由于Chrome 12已经停止运行。不关心其他浏览器,但在更新版本的Chrome中使用它变得越来越重要。

简而言之,我调用一个PHP数据页(不是跨域)并返回一个JSON数组,该数组被迭代,将响应元素插入到本地SQLite数据库中。

控制台日志不会引发任何标记,也不会出现javascript错误。我在响应中看到了JSON,而且似乎中断的唯一部分是try块中的数据插入。

任何人都知道版本11之后的Chrome是否会发生变化,这会阻止与SQLite数据库的交互?任何帮助都将非常感激。

function importAssignmentData() 
{
var import_count = 0;
$.get("data.php", function(data) {
    if (data instanceof Array){
        // Data is properly formed as an array.
    }
    else{
        alert('Data from the server was not properly formed. You may not be logged in.');
    }
    $.each(data, function(index, value) { 
        if (this.order_id == 'authfail'){
            alert("You are not logged into the server. Authentication failure.");
            console.log("Authentication failure.");
        }
        else{
            if (typeof this.order_id != 'undefined') { // sanity check    
                import_count++;
                var EMPTY               = "";
                var order_id            = (this.order_id == '') ? EMPTY : this.order_id;
                var order_code          = (this.order_code == '') ? EMPTY : this.order_code;
                var customer_id         = (this.customer_id == '') ? EMPTY : this.customer_id;
                var customer_name_first = (this.customer_name_first == '') ? EMPTY : this.customer_name_first;
                var customer_name_last  = (this.customer_name_last == '') ? EMPTY : this.customer_name_last;
                var customer_phone      = (this.customer_phone == '') ? EMPTY : this.customer_phone;
                var customer_email      = (this.customer_email == '') ? EMPTY : this.customer_email;
                var customer_address    = (this.customer_address == '') ? EMPTY : this.customer_address;
                var customer_city       = (this.customer_city == '') ? EMPTY : this.customer_city;
                var customer_state      = (this.customer_state == '') ? EMPTY : this.customer_state;
                var customer_zip        = (this.customer_zip == '') ? EMPTY : this.customer_zip;
                var order_notes_contractor = (this.order_notes_contractor == '') ? EMPTY : this.order_notes_contractor;
                var measurement_date    = (this.measurement_date == '') ? EMPTY : this.measurement_date;
                try {
                    ODATA.transaction(function (transaction, results){transaction.executeSql("INSERT INTO order_specs (order_id, order_code, customer_id, customer_name_first, customer_name_last, customer_phone, customer_email, customer_address, customer_city, customer_state, customer_zip, order_notes_contractor, measurement_date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", [order_id, order_code, customer_id, customer_name_first, customer_name_last, customer_phone, customer_email, customer_address, customer_city, customer_state, customer_zip, order_notes_contractor, measurement_date], nullDataHandler, errorHandler);});
                    console.log("Order record inserted.");
                }
                catch(e) {
                    console.log(e.message);
                }                           

            }
            else {
                alert('You are not online, or you may not be logged in properly.');
                console.log("Offline attempt to retrieve remote data. No inserts made.");
            } // end sanity check
        } // end authfail check
    }); // end .each
    var plural = (import_count == 1) ? "" : "s" ;
    alert('You have ' + import_count + ' active assignment' + plural + '.\nClick List Assignments to view your assignments.');
    $('#reload_page').focus();
});
}

1 个答案:

答案 0 :(得分:0)

结果证明这与jQuery 1.5.2有些不兼容。不确定涉及的内部或细节,但此时我甚至不关心。

升级到jQuery 1.6.4库解决了这个问题。

我现在要梳理一下我留下的小头发 - 希望这会帮助其他人留下更多的头发。