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

402
Vistas
Form submission working, but CORS issue with ajax

I have a form with an action to the site that processes the post. When I hit submit with the url in the action, it works. Problem is, when the form is submitted or if there is an error, it takes me to another page so show "success" or "error" (I don't want it to take me to the other page, just return the response to my page so I can make a modal or something). I have tried many different ways, but when I use AJAX, I get the "Access-Control-Allow-Origin". Why would I get this if I'm already allowed to make the post without it?

Works when form header is:

form accept-charset="UTF-8" class="" id="contestForm" enctype="multipart/form-data" action='url' method='post'>

Example of requests I've made.

$.ajax({
  method: 'POST',
  url: url,
  dataType: 'json' or 'jsonp',
  headers: {'Access-Control-Allow-Origin: *},
)};

etc., etc. (Sorry that may not be complete as I have started over again before asking the question). Any idea how to not go to the submit page upon hitting the submit button?

P.s. I am using Flockler for the submissions and I have no control over how the data is posted to their server.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Please add the CORS header ‘Access-Control-Allow-Origin:<requster_domain>’ in the server to accept your request. Thru Ajax it opens up a security threat so the browsers block it which makes sense. else anyone can open a browser console and may bombard the server with ajax calls. But if your server trusts the calls coming from your domain, that security risk is mitigated.

I hope this helps.

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