Reputation: 4813
I try to submit a laravel form exactly like this example :
$.post('/ajax/post', {payload:'hello'}, onSuccess);
When i try to get access the payload string 'hello'
using :
$request->get('payload');
I get null
.
Upvotes: 1
Views: 210
Reputation: 67525
Try to get it using input
:
$request->input('payload');
And you could first check the developpers console under network tab to make sure that the variable is sent by the post request.
And you could always check the attributes of the request using :
dd($request);
Hope this helps.
Upvotes: 1
Reputation: 183
Test Your variable inside your javascrip
// handlers
function onGetClick(event)
{
// we're not passing any data with the get route, though you can if you want
console.log(get your variable)
$.get('/ajax/get', onSuccess);
}
Maybe your variable has no data
Upvotes: 0