qteck
168
5
Laravel

POST method, AJAX and routes

Posted 8 months ago by qteck

Hello,

I cannot get my POST form running. When I use the method GET and the GET route, it works.

Route::post('knihy/platba', 'Knihy\[email protected]');

$.ajax({ url: "/knihy/platba/", method: "POST", dataType: 'json', data: { 'forename': "John", '_token': token },

                              success(s){console.log("success"+token);},
                              error(e){console.log("unsucess");}
                })

knihy/platba

function paypalPayment(Request $request) {
    //dd($request);

    $orders = new Orders($request->all());
    $orders->save();
    return json_encode(array('state' => 1));
    exit;
}

when using the get method it goes through and return the json response.

when I use the POST method laravel gives out: oups something went wrong. and the .log is empty.

thank you.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.