Sunday, March 5, 2017

How to debug Laravel 406 for Ajax Request

I am getting 406 Not Acceptable error for some ajax request. I am sending a Ajax request to the store(). Some request will pass some will fail with 406 error. How to debug this? I added echo "test"; die; in the starting of store. But in failure cases its not at all hitting there. From where should I start debugging? I am very new to Laravel, when I googled I came across a solution to modify ajax header but when I modified its failing in all the request. I believe it may be something related to the input as its failing on the particular request. but I couldn't able to make out any difference between the input data, only difference I can say is success case I am passing more data, and in failure data size is less. sample data,

var data =
    [ {
        id : 1,
        html : "<html string>",
        x : 0,
        y : 1,
        data : "string formatted JSON data"
    } ];

$.ajax({
    type : "POST",
    url : actionURL,
    data : {
        data : JSON.stringify(data)
    },
    success : function(res){},
    error : function(err){}
});

Where should I start debugging in the failure case? Is there any suggestion to fix this issue?



via Gilson PJ

Advertisement