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

274
Visualizações
$.ajax vs $.post : getting allow origin error

Doing ajax using this is fine :

$.post("http://localhost:3000/scrape",
            {
                data: json
            },
            function(data, status){
            });

but this is not?

$.ajax({
              type: 'POST',
              url: 'http://localhost:3000/scrape',
              data: json,
              contentType: "application/json",
              success: function(data,status){

              },
              async:false
            });

With $.ajax I got the error of XMLHttpRequest cannot load http://localhost:3000/scrape. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I thought both of them are the same? What's the problem here?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

In the first example you are making a simple request with application/x-www-form-urlencoded data.

In the second example you are specifying a content type which isn't one of the ones allowed for simple requests, so you are triggering a preflighted request.

The server is responding happily to the POST request, but not to the preflight OPTIONS request.

over 4 years ago · Santiago Trujillo 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