I have the next code:
$.get('Lubricantes/getListaEquipos', function (data) {
if (data.length > 0) {
var peticion = base_datos_local.transaction(['Equipos'], 'readwrite').objectStore('Equipos').clear();
total_equipos = data.length;
peticion.onerror = function () {
console.log('No se pudo limpiar el maestro de equipos.');
};
peticion.onsuccess = function (e) {
for (var i = 0; i < data.length; i++) {
var peticion = base_datos_local.transaction(['Equipos'], 'readwrite').objectStore('Equipos').add(data[i]);
peticion.onerror = function (e) {
console.log('No se pudo cargar el equipo' + i);
};
peticion.onsuccess = function (e) {
console.log('Equipo ' + i + ' agregado');
};
}
};
}
});
When this execute the var i don't exist, how can pass to add method the value of i?