I have a javascript/jquery function in an offline-capable web app that works great in Chrome 11, but since Chrome 12 has ceased to work. Don’t care about other browsers, but getting this working in more recent versions of Chrome is getting more and more critical.
In a nutshell, I call a PHP data page (not cross-domain) and get back a JSON array, which gets iterated over, inserting elements of the response into the local SQLite db.
The console log raises no flags, and no javascript errors. I see the JSON in the response, and the only part that seems to break is the data insert found in the try block.
Anyone know if there was a change in Chrome after version 11 that would prevent interaction with the SQLite db? Any help would be most appreciated.
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();
});
}
This turned out to be some incompatibility with jQuery 1.5.2. Not sure of the internals or specifics involved, but at this point I do not even care.
Upgrading to jQuery 1.6.4 library solved the problem.
I will now go comb what little hair I have left – hopefully this will help others out there keep more of theirs.