I have million rows in my DB. I need to export all them into csv file. The problem is that i have timeout limit error.
So. I decided to do it via ajax.
I created ajax that generates me few tmp csv files
function chunkedExport()
{
$.ajax({
type: "POST",
url: "transactions/",
dataType: "JSON",
data: $("#transactions").serialize(),
async: false,
success: function(response)
{
if (response.status === "continue")
{
$("#start_from").val(response.start_from);
$("#client_file_name").val(response.client_file_name);
$("#file_name").val(response.tmp_file_name);
$("#step").val(response.step);
chunkedExport();
} else {
console.log('DOWNLOAD');
$("#start_from").val(0);
$("#client_file_name").val('');
$("#file_name").val('');
$("#step").val(1);
$("#export_type").val("");
$('#csv_format').val("");
document.location.href = '/transactions_export_csv/'+response.client_file_name+'/'+response.tmp_file_name+'/'+response.total_iterations+'/'
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log([xhr, ajaxOptions, thrownError]);
$("#start_from").val(0);
$("#client_file_name").val('');
$("#file_name").val('');
$("#step").val(1);
$("#export_type").val("");
$('#csv_format').val("");
}
});
}
the question is how to combine them all into one csv file and download it?