0
I have a Javascript function that sends requests with the content of a line textarea
, is a looping that traverses an array and sends requests with the data of these indexes of the array, the problem is that we need to create 1 more array with the content of another textarea
and send simultaneously with the array of the first textarea
, in the case:
<script>
function enviar(){
var bin = $("#bin_id").val();
var linhaenviar = bin.split("\n");
var cor = coloracao.split("\n"); //esse e o textarea do qual quero criar o array
var index = 0;
linhaenviar.forEach(function(value){
setTimeout(
function(){
$.ajax({
url: 'bancodedados.php',
type: 'POST',
dataType: 'json',
data: 'nome=' + value + 'cor=' +arraycor,
success: resultado
})
}, 10 * index);
index = index + 0;
})
}
</script>
what I’m doing this is the best way
– Estudante PHP
I am sending line by line from a single textarea, but need to send line by line from two textareas at the same time in a single request
– Estudante PHP
no, the quantity will vary depending on the data received
– Estudante PHP
So it pays to make a request only, and work with the data on back-end.
– NoobSaibot
this will open 1 process only using a looping in php itself and let the return of the answers slow, need the looping stay in js this way opened multiple processes in php file working as threads and the return of each request will be faster
– Estudante PHP
Multiplying the time in
10 * index
serves what?– Sam