繁体   English   中英

Laravel Routes / jQuery $ .post()返回404找不到

[英]Laravel Routes/jQuery $.post() returning 404 Not Found

包含jQuery的Java文件,用于发送POST请求。

$.post('sign_in', { email: email, password: password }, function(result) {
    $('#sign_in_result').html(result);
    console.log(result);
});

包含POST路由的Laravel route.php文件。

<?php

Route::get('/', 'HomeController@showWelcome');

Route::post('sign_in', function() {
    return 'Test';
});

而不是返回测试,什么也不返回。 在控制台中,显示404 Not Found。

POST http://localhost/project/public/sign_in 404 (Not Found)

尝试使用URL类为您的路线构建URL,因此:

$ .post('sign_in',....

变成:

$ .post('{{URL :: to('sign_in')}}',....

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM