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

390
Views
Why does AJAX success function doesn't work?

I don't know why that success doesn't work. I even saw later someone having same code and it worked.

function doButtonUpdate(buttonNumber) {
    $.ajax({
        dataType: "json",
        method: "POST",
        url: '/Button/ShowOneButton',
        data: {
            "buttonNumber":buttonNumber
        },
        
        success: function (data) {
            console.log(data);
            $("#" + buttonNumber).html(data);
        }
    })
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In the dataType parameter you specify "json", which means this is the type of data you are expecting to receive from the server.

But since you are directly inserting received data into the HTML, I suspect you are not receiving a valid json response (maybe HTML or just plain text?). Hence the success callback is not executed. Try leaving out this parameter, which should then fall back to an "intelligent guess" for the received data type.

https://api.jquery.com/jquery.ajax/

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!