0
I make a request AJAX in view
and a survey on database. I need to compare the results of the two and if an item is equal I want to print a result in a div
$.ajax({
type: "GET",
data: {number: 48996713742},
url: 'http://consultaoperadora1.telein.com.br/sistema/consulta_json.php?chave=' + senha +'&numero=' + number,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
beforeSend: function(){
$("#content").html('');
},
success: function(data){
var item = JSON.parse(data);
$('#operadora').val(item.operadora);
var operadora = item.operadora;
console.log(item.operadora);
phone = '(' + item.numero.substr(0, 2)+ ') ' + item.numero.substr(2, 5) + '-' + item.numero.substr(6,4);
$('#content').append('\
Número: '+ phone +'\
Operadora: '+ operadora +'\
')
@if(count($operators) > 0)
@foreach($operators as $item)
@if($item->code == 'operadora')
$('#content').append(item.operadora)
@endif
@endforeach
@endif
}
})
Bro, don’t mix like that. Everything in its place...
– Diego Souza
I’m trying, but I don’t know how
– Edinho Rodrigues
You have to compare on the route where you do AJAX, in PHP.
– Diego Souza