I'm having a trouble with an Ajax request, I want to post some data using jQuery. I have to say that before with GET
it works fine, but I have a lot of data to send and I get: (Request-URI Too Long)
so, for that I'm changing to post.
I'm working on Laravel, I changed the route from get to post, the method in the controller is called correctly, but for some reason the ajax petition doesn't send the data (groups and segments).
Groups and segments are Javascript arrays, as I said, it works fine with GET but it fails when the data is too long.
My current code looks like this:
$.ajax({
type: "POST",
data: {groups:groups, segments:segments},
url: "check",
success: function(msg){
//something...
});
});
I tried too adding this lines:
contentType: 'application/json; charset=utf-8',
But I had the same result, I get error 500 when I try to read the variables in the controller.
My route in Laravel is:
Route::post('check',array('as'=>'check','uses'=>'FileController@checkfile'));
if I put return 'Hallo!';
the text is returned as well, then, to see all the variables that are sended to the controller I made:
dd(Input::all());
but it prints an empty array. So, for what I see the problem is not the route but the way as I am sending the data with ajax Thanks!