Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda