Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

392
Views
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.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

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.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!