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

113
Views
Why AJAX POST request failed?

I have simple a html page with form. When I do POST request then receive failed, but it not response from server. What I do wrong?

function createRequest(url, body) {
    var response;
    console.log(JSON.stringify(body)); // (1)
    $.ajax({
        url: "creation/" + url,
        type: "POST",
        async: false,
        contentType: 'application/json',
        data: JSON.stringify(body),
        success: function (data) {
            if (data.status == true) {
                response = data.response;
            } else {
                BootstrapDialog.show({
                    title: 'Error',
                    message: data.errorMessage
                });
            }
        }
    });
    return response;
}

Body (1)

{"name":"Test UI","bid":"2","budget":"20"}

When I do this request via POSTMAN all work fine.

jQuery

Error appaear in Chroome Version 57.0.2987.98 (64-bit), but in Edge all works fine enter image description here

enter image description here

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Since there isn't much information you have shared; here are some tips you could use to debug your problem based of assumptions where I think the problem is at.

  1. debug your code by using a console.log(data) as the first thing in your code to make sure if you're accessing the right fields.
  2. data.status is usually a status code 1xx,2xx, 3xx, 4xx and 200 means the success of a request. I check if a response is successful like this data.status == 200, but you used data.status == true you should log the data to make sure you're using that correctly otherwise you'll always get a logged error.
  3. JSON.stringify(body) will convert the body into a string and the data field of an ajax call takes an object with parameters to pass in its request. Is JSON.stringify(body) really what you meant to do or is it just body?

Well if you decide to add more information I'll be sure to update the answer with additional suspicions.

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!