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

269
Views
$.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 answers
Answer question

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