function aggiornaTagsToPosts(id, tagId) { FONTE.dbHandler.executeSql('INSERT INTO xm24_tags_to_posts VALUES (?,?)', [id, tagId], function (resultSet) { console.log('resultSet.insertId: ' + resultSet.insertId); console.log('resultSet.rowsAffected: ' + resultSet.rowsAffected); }, function (error) { console.log('INSERT error: ' + error.message); //feedback $("#aggiorna").attr("src", "./image/aggiorna.png"); }); } function aggiornaTags(pagenum) { var jsonurl = weburl + "wp-json/wp/v2/tags?per_page=100&page=" + pagenum; $.ajax({ dataType: "json" , url: jsonurl , success: function (data, status, xhr) { var totalPages = parseInt(xhr.getResponseHeader("X-WP-TotalPages")); $.each(data, function (key, val) { var name = val.name; var slug = val.slug; var id = val.id; var blob = JSON.stringify(val); FONTE.dbHandler.executeSql('INSERT INTO xm24_tags VALUES (?,?,?)', [id, slug, blob], function (resultSet) { console.log('resultSet.insertId: ' + resultSet.insertId); console.log('resultSet.rowsAffected: ' + resultSet.rowsAffected); }, function (error) { console.log('INSERT error: ' + error.message); }); }); pagenum += 1 if (pagenum <= totalPages) aggiornaTags(pagenum) } , error: JSONErrorHandler }); };