Menu

Saturday, November 13, 2021

Get error 500 Internal issue during ajax response


The 500 Internal Server Error is a very general HTTP status code. It means something has gone wrong on the website and the webserver is unable to specify what exactly, thus failing in fulfilling the request made by the client. This is not related to the client and the fault is in the webpage/website requested that resides on the server. This status code can be considered as a ‘catch-all’ server error of the Web server.


Here you can try this,


$.ajax({
            url: 'getdemo', 
            type: 'POST',
            data: {id: id},
            beforeSend: function (request) {
                return request.setRequestHeader('X-CSRF-Token', $("meta[name='csrf-token']").attr('content'));
            },
            success: function (response) {
               console.log(response);
            },
            error: function (err) {
                console.log(err);
                alert("Oopss, Something Went Wrong");
            }
        });