Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return the 500 error message using jQuery .load() or .get()

I am trying to make AJAX calls using the jQuery .load() method. When the request passes, it loads the return data correctly. If I get a 500 error, it does not. Is there a way to output the failed request message information as well?

$("#activity").load("/forumsetup", { id:myid }, 
       function(data) {
          $("#restart").css("visibility","visible");
        });  

I can see it in firebug, but would like to load it onto my page.

like image 530
JiminyCricket Avatar asked Apr 20 '26 11:04

JiminyCricket


1 Answers

From jQuery doc page: http://api.jquery.com/load/

$("#success").load("/not-here.php", function(response, status, xhr) {
  if (status == "error") {
    var msg = "Sorry but there was an error: ";
    $("#error").html(msg + xhr.status + " " + xhr.statusText);
  }
});
like image 198
Alxandr Avatar answered Apr 23 '26 03:04

Alxandr