Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

136
Visualizações
$.get how to add headers using laravel

i want to add this headers

headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
},

to my $.get jquery request

$('.wilayas').on('change', function(x) {
        /*             
                    $('.dayras').find('option')
                        .remove()
                        .end() */
        alert(this.value)

        $.get("{{ route('customer.auth.dayras') }}", {
                data: this.value
            },
            function(data, status) {
                alert(data);
                $('.dayras').append(`
             <option value="-">-</option>
        `);
                data.map(dd => {
                    $('.dayras').append(`
             <option value="${dd.id}">${dd.dayra}</option>
        `);
                })
            });
    });

am getting the html response instead of json

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The syntax of the jQuery ajax headers option :

$.ajax({ 
    headers: {          
        "Accept": "text/json"
        "Content-Type": "application/json"
    }    
    ...
    ...
});

The syntax of the jQuery ajax headers option set or overwrite with the beforeSend callback function :

$.ajax({
    url: "{{ route('customer.auth.dayras') }}",
    data: { foo: bar },
    type: "GET",
    beforeSend: function (jqXHR, settings) { 
        jqXHR.setRequestHeader("Accept", "text/json");
        jqXHR.setRequestHeader("Content-Type", "application/json");
    }
    ...
    ...
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda