简体   繁体   中英

Debugging jQuery ajax 500 Internal server error

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?

You can try using alert(xhr.responseText); or console.log(xhr.responseText); (the later will show up in your browser console eg 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);
       }

Please see my response here . It is a full explanation on how to do ajax debugging with CodeIgniter and jQuery.

You need to configure the webconfig file to receive POST request.

 <system.web>

    <webServices>
      <protocols>
        <add name="HttpPost" />
      </protocols>
    </webServices>
 </system.web>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM