首页 > 解决方案 > 如何为ajax url laravel调用控制器功能

问题描述

我正在通过 ajax url 从视图(resources\views\customer\edit_order.blade.php)使用控制器(OrdersController)的功能(交付更新)。我的 javascript 位于localhost:8072/myapp/public/theme/js/custom.js

$.ajax({        
        url: 'delivery-update',
        type: "POST",
.....

但是当我在网络控制台中调试 url 时。请求将发送到 urllocalhost:8072/myapp/customer/edit_order/delivery-update但我需要 url 请求localhost:8072/myapp/orders/delivery-update

我试过了,

url: 'orders/delivery-update'   //but it takes to localhost:8072/myapp/customer/edit_order/orders/delivery-update

我的路由.php

Route::post('orders/delivery-update', 'Admin\OrdersController@delivery_update');

请。任何建议都会很棒..

标签: phpajaxlaravelurlroutes

解决方案


推荐阅读