Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

268
Vistas
$.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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda