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

115
Views
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 answers
Answer question

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 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!