Can anyone tell me how to send arrays like this? php always getting null $_POST
2
-
1Please check this question stackoverflow.com/questions/15994950/…karthzDIGI– karthzDIGI2018-12-01 14:43:14 +00:00Commented Dec 1, 2018 at 14:43
-
Possible duplicate of How can I send a javascript array to a PHP script using Ajax along with other non-array data?Wayne Phipps– Wayne Phipps2018-12-01 17:05:47 +00:00Commented Dec 1, 2018 at 17:05
Add a comment
|
1 Answer
I'm not sure what you're trying to do, you didn't provide enough information. This is a simple example where i'm sending user and email. I hope this can help you.
AJAX:
$.ajax({
type: "POST",
url: "post_route",
data: {user:'xyz', email:'[email protected]'},
success: function (data) {
console.log(data);
}
});
Route:
Route::post('/post_route', 'TestController@post');
Controller:
public function post(Request $request){
if($request->ajax()) {
//return dd($request);
$user = $request->get( "user" );
$email = $request->get( "email" );
}
1 Comment
Damian Kroplewski
I'd want to send my whole array i prepared(console log image) VIA Ajax data. While im trying to send my array, PHP $_post is just empty
