Compare Database Data with AJAX Result

Asked

Viewed 67 times

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
        }
    })

inserir a descrição da imagem aqui

  • Bro, don’t mix like that. Everything in its place...

  • I’m trying, but I don’t know how

  • 1

    You have to compare on the route where you do AJAX, in PHP.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.