I have a method in the controller that inserts a table, and I want the bar to increase for each insert, but this loop is in the controller. Is there any way to do that?
//codigo javascript
$.ajax(
{
type: 'get',
url: "{{ route('ruta') }}",
data: { 'p1' : p1,
'p2' : p2 },
dataType: 'JSON',
xhr: function() {
var xhr = new window.XMLHttpRequest();
xhr.addEventListener("progress", function(e){
if(e.currentTarget.response.trim() == ''){
recibidos++;
aumentarBarra(recibidos);
}
});
return xhr;
},
success: function(data)
{
//codigo del success
}
});
//php
function Metodo(Request $request){
@ini_set('zlib.output_compression', 0);
header("Content-Type: text/html; charset=utf-8");
if (ob_get_level() == 0) ob_start();
.. la la la se hacen unas busquedas
$ids = [1, 2, 3, 4];
foreach($ids as $key => $id){
//hacer un insert a la tabla
echo ' ';
ob_get_contents();
ob_flush();
flush();
}
}
It works, but on the test server, I do not have access to the php.ini or the server settings, so I think the flush does not work, is there any other way to do it?