1

我收到以下错误:

未捕获的错误:INVALID_STATE_ERR:DOM 异常 11

尝试执行查询时收到此错误消息。

有没有人遇到过同样的问题?

function populateDB(tx) {

    tx.executeSql('DROP TABLE IF EXISTS ORDERS');
    tx.executeSql('CREATE TABLE IF NOT EXISTS ORDERS (id INTEGER PRIMARY KEY, client_ID, status)');

    var myurl="xml.xml";
    $.ajax({
        type: "POST", 
        url: myurl, 
        dataType: "xml", 
        success: onSuccess
    }); 
}

function onSuccess(xml) {

    $(xml).find('articles').each(function () {
        var idord = $(this).attr('id');

        var esql ='INSERT INTO ORDERS (id, client_ID, status) VALUES ('+idord+', 4, "done" )';
        var nameclient = $(this).find('name').text();
        $('.items').append('<h2>'+ nameclient '</h2>').appendTo('#xml-data'); 

        tx.executeSql(esql) ;
    });  
}
4

1 回答 1

0

尝试在函数中定义onSuccess函数populateDB,如下所示:

function populateDB(tx) {

    tx.executeSql('DROP TABLE IF EXISTS ORDERS');
    tx.executeSql('CREATE TABLE IF NOT EXISTS ORDERS (id INTEGER PRIMARY KEY, client_ID, status)');

    var myurl="xml.xml";
    $.ajax({
        type: "POST", 
        url: myurl, 
        dataType: "xml", 
        success: function(xml) {

            $(xml).find('articles').each(function () {
                var idord = $(this).attr('id');

                var esql ='INSERT INTO ORDERS (id, client_ID, status) VALUES ('+idord+', 4, "done" )';
                var nameclient = $(this).find('name').text();
                $('.items').append('<h2>'+ nameclient '</h2>').appendTo('#xml-data'); 

                tx.executeSql(esql) ;
            });  
        }

    }); 
}

让我知道这是否可行。

于 2012-09-20T11:20:10.707 回答