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

113
Vistas
jQuery AJAX does not detect success

I have the following code.

$(".likeBack").on("click", function(){
  var user = $(this).attr("user");
  var theLikeBack = $(this).closest(".name-area").find(".theLikeBack");
  $.ajax({
    type: "POST",
    dataType: "json",
    url: "processes/rewind-knock.php",
    data: "user="+user+"&type=likeback",
    success: function(json){
      alert("SUCCESS");
    },
    error: function(jqXHR, textStatus, errorThrown){
      alert("XHR: " + jqXHR + " | Text Status: " + textStatus + " | Error Thrown: " + errorThrown);
    }
  });
});

Here, everything is functional. Network tab shows request and response well received as required. However, the success part is not getting executed. I tried adding beforeSend and complete and both are getting executed but success part (nothing inside the success blog is getting executed). I don't understand the reason why.

UPDATE

Add error part. It returns:

XHR: [object Object] | Text Status: parsererror | Error Thrown: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

UPDATE 2

Screenshot

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

give data in ajax like this and check,

data : {'user':user,'type':'likeback'},

In your Php code when you return the data, place all data in a array then use this, echo json_encode($arr); //return the array in json form

now in your success function use console.log(JSON.parse(json));

hope may help you. Thank you

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