0
I have a jQuery with $.ajax
who sends a request to my config.php
which in turn returns a json_array
:
function enviar(){
var bin = $("#bin_id").val();
var linhaenviar = bin.split("\n");
var index = 0;
linhaenviar.forEach(function(value){
setTimeout(
function(){
$.ajax({
url: 'config.php',
type: 'POST',
dataType: 'html',
data: "bin=" + value,
success: function(resultado){
}
})
}, 10 * index);
index = index + 1;
})
}
The returned array is this:
"{\"pergunta\":\"qual a cor do céu\",\"resposta\":\"azul\",\"status\":\"acertou\"}"
What I don’t understand is how to manipulate this data config.php
returns, printing the wrong answers in div id="erro"
according to the status.
You should be wearing
dataType: 'json'
instead ofdataType: 'html'
– Sergio
is that this ajax makes the request sending data to a php that will generate the json with the data sent, if I change something in sending this data ?
– Estudante PHP
No, the
dataType
only refers to the expected return.– Sergio