Laravel Ajax 提交 404 错误

路由


Route::group(['prefix' => 'ajax', 'namespace' => 'Ajax'], function() {
    Route::post('/mstore/morders', 'SitesController@morders');
});

    public function morders(Request $request)
    {
        return true;
    }

js 代码


$.ajax({
                    url : "{{ URL::to('/mstore/morders') }}",
                   type : "post",
                   traditional:true,
                   data:{"strorderid[]":strorderid,"strordernum[]":strordernum,"customname":customname,"customphone":customphone,"customaddress":customaddress},
                   dataType : "JSON",
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                   success : function() {
                       alert("成功");
                   }
                });

提交或者直接访问 http://yueyu-laravel:8888/mstore/morders 都是 404 错误,一晚上没招到问题,小白求指点,谢谢。

《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
讨论数量: 18

楼主,你当初的问题解决了吗?我用 ajax 的 post 请求,也是报错 161,
错误截图如下

file
我的 ajax 请求是

file
路由是

file
我知道好像是路由错了,但是我又这个路径的方法

file
我不知道怎么改了,请帮助我!

7年前 评论

@CN 不好意思 当时解决是解决了,但时间太久忘了是哪里的问题了......

7年前 评论