-4

enter image description here

Can anyone tell me how to send arrays like this? php always getting null $_POST

2

1 Answer 1

0

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" );
    }
Sign up to request clarification or add additional context in comments.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.