Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

115
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda