I got a ajax request to a method, where I send some data to.
My ajax call is as follows:
$.ajax({
url: btn.data('url'),
type: 'POST',
data: {_method: 'delete', _token: token, items: JSON.stringify(_items)},
success: function () {
//
}
})
Where token
is read from a meta tag and _items
is an array with ID's.
When I inspect this ajax call, the form data contains:
_method:delete
_token:15KeBPmbt7WVgm8KNCWG4idqCw3FpGykzREPn8fu
items: ["4","11","15"]
But when I dd(json_decode(Input::get('items')
it returns:
0: 3
1: 0
2: 4
3: 1
4: 1
5: 11
6: 2
7: 2
8: 15
9: 2
Edit: when I remove the JSON.stringify the formdata contains:
items[]:1
items[]:2
and returns a array of:
0: 2
1: 0
2: 1
3: 1
4: 1
5: 2
6: 1
Here is my route catch:
Route::delete('user/destroy/multiple', function() {
dd(Input::get('items'));
});
I really don't know what going wrong...