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

401
Visualizações
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 Respostas
Responde à pergunta

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