Debugging jQuery ajax 500 Internal server error

ajax, jquery

Solution

You can try using `alert(xhr.responseText);` or `console.log(xhr.responseText);` (the later will show up in your browser console e.g. firebug) in your error callback, doing so you can get the message associated with the exception (if any).

error: function (xhr, ajaxOptions, thrownError) {
           alert(xhr.status);
           alert(xhr.responseText);
           alert(thrownError);
       }

or

error: function (xhr, ajaxOptions, thrownError) {
           console.log(xhr.status);
           console.log(xhr.responseText);
           console.log(thrownError);
       }

Problem

My working CodeIgniter site is giving a 500 Internal Server Error while hosting it on MediaTemple. It is happening during a jQuery Ajax call. I have no idea what could have gone wrong. Is the error from the controller or the model? My Ajax call: ``` $.ajax({ url: "<?php echo site_url('invites/save_email') ?>", type: 'POST', data: form_data, success: function(msg) { window.location.href = "<?php echo site_url('invites/moreinvites')?>" return true; }, error: function (xhr, ajaxOptions, thrownError) { alert(xhr.status); alert(thrownError); alert(xhr.responseText); } }); ``` xhr.responseText has returned me `<p>The action you have requested is not allowed.</p>`. But what does that mean?

Original source

Related problems