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

143
Views
Python request works, ajax not

I have working requests code in python and need it in ajax

var jsonData = {"x":"y"};

$.ajax({
  url: url,
  type: 'POST',
  data: jsonData,
  //dataType: "JSON",
  
  error: function(e) {
    console.log(e);
  }
  
});

json: jsonData, JSON.stringify, 'Content-Type': 'application/json' and changing names doesn't work, I tried a lot of things, but everytime error 400

this python code works fine

payload = {
    'a':'b',
    'a': 'b'
}


#but it doesn't work with field 'data' or 'params', must be named 'json'
r = requests.post(url, json=payload) #data=payload won't work, otherwise error 400
print(r.text)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

try setting contentType: "application/json" on ajax

about 4 years ago · Juan Pablo Isaza 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!