包含发送POST请求的jQuery的Javascript文件
$.post('sign_in', { email: email, password: password }, function(result) {
$('#sign_in_result').html(result);
console.log(result);
});
包含POST路由的Laravel routes.php文件。
<?php
Route::get('/', 'HomeController@showWelcome');
Route::post('sign_in', function() {
return 'Test';
});
不返回test,而是不返回任何东西。在控制台中显示404 Not Found.
POST http://localhost/project/public/sign_in 404 (Not Found)
尝试使用URL类来构建路由的URL,因此:
$。帖子(sign_in,…
就变成:
$。post('{{URL::to('sign_in')}}', ....