Hey guys, 3:36am and I'm needing a mental boost.
Simple question, what is the easiest/fastest way to add 100 points to a database. Please assume all writes will not work due to duplicates, bad data, etc.
I'm trying to update a database with exactly 100 values.
Once I have a good piece of data, I need to add it to the database and I use a function called updateDB.
This function just writes a lat/lng coordinate to the database. If there is a duplicate or the write fails, I send "error" from php and the loop should continue collecting data until I have exactly 100 points to the database. Here's the function I'm using.
cct is used for xss prevention, please ignore it, this works fine.
////more above this
if(100-completed > dispatched)
dispatched++;
updateDB(lat,lng);
/// more junk and then this function
function updateDB(lat,lng)
{
var cct = $("input[name=csrf_mysite]").val();
$.ajax({
type: "POST",
url: "/form",
data: {
'lat': lat,
'lng': lng,
'id_set': id_set,
'csrf_complexity': cct },
success: function(result) {
var obj = jQuery.parseJSON(result);
if( obj.status === "OK" )
{
completed++;
var marker = new google.maps.Marker(
{
icon: markerIcon,
position: new google.maps.LatLng(lat, lng),
map: map
});
$( "#progressbar" ).progressbar( "option", {
value: completed,
max: 100
});
$("#amount").text("Getting image " + completed + " of 100");
}
},
error: function(data){
//alert(data.responseText);
},
complete: function(data){
if(completed == 100)
window.location = "/start/curate";
dispatched--;
}
});
}
This function does not work. So any idea why?
It should work simply. Call updateDB until it either reaches 100 added values and only call updateDB when there is no possibility that there will be extra calls. Dispatch does not decrement properly so I'm assuming complete isn't called on every event.
Ideas? Or any other way to do this would be awesome.