I am currently building a offline app which will be used on mobiles they will be uploading lots of data.
Everything works great, but I would like to remove the objects out of the database when they upload successfully.
I have * where it should be doing that, any one have ideas why this is not working?
function uploadData(e) {
var transaction = db.transaction(["data"], "readonly");
var objectStore = transaction.objectStore("data");
var cursor = objectStore.openCursor();
cursor.onsuccess = function(e) {
var res = e.target.result;
if(res) {
if (navigator.onLine) {
var passData = {
offer: res.value.offer,
created: res.value.created,
image: res.value.image,
};
var jsonData = JSON.stringify(passData);
$.ajax({
url: "{{ path('destination_app_ajax') }}",
type: "post",
data: {
"json": passData
},
success: function(JsonData) {
*This should delete out of indexeddb
transaction.objectStore("data").delete(res.key);
},
error: function() {
$('.popup-heading').text('Some items didn't upload try again!');
}
});
}else{
$('.popup-heading').text('Please find stronger signal or wifi connection');
}
res.continue();
}
}
}