在我看來有一種形式,點擊提交後,數據被帶到ajax腳本中,該腳本應該調用routes.php中的後路由中指定的控制器。預計控制器會處理接收到的數據並將結果返回到視圖。爲什麼提交表單後立即出現此錯誤,並如預期>Laravel在提交表單時出錯:RouteCollection.php中的MethodNotAllowedHttpException行218.這可能是由什麼引起的?
回答
檢查routes.php文件文件的東西不工作。確保你使用的方法符合你允許的方法。
Here is the laravel documenation for routes
例如,如果您的請求是GET請求,調用應該是這樣的路線文件:
Route::get('/test-get-url', function() {
// Matches The "/test-get-url" URL using a GET method
});
而對於後
Route::post('/test-post-url', function() {
// Matches The "/test-post-url" URL using a POST method
});
轉到終端/ cmd..whichever您使用並鍵入
php artisan route:list
這將列出所有你的路由,並在方法列中使用什麼路線你正在submitted.Note相應的方法檢查,並使用該方法同時提交form.I'm假設它是PUT
方法(這是最有可能).Ex--
使用method
屬性,如果你正在使用簡單的HTML代碼like--
<form action="{{route='..'}}" method="PUT">
,或者如果你正在使用的形式助手,那麼use--
{!! Form::open($post, ['route' => ['..'], 'method' => 'PUT']) !!}
轉到您的route.php文件並檢查
Route :: get('someroute',['uses'=>'somecontroller @ function_get','as'=>'some_get']); Route :: post('someroute',['uses'=>'somecontroller @ funtion_post','as'=>'some_post']);
確定您是否在使用(as)路由它的不同以及您在何處使用您的ajax您正確定義了您想要發佈表單數據的路由,並且它的類型與您在路由中提及的路由相同還有一點你檢查正確使用(;)在你的代碼
希望這將幫助你愛上免費問您的查詢
沒有。還是行不通。在這裏:https://pastebin.com/F52Hn8zQ –
你能在評論發送您的路由文件,我覺得可能是可能被留下,或者說忘了在阿賈克斯網址 –
這裏是一些前綴組:https://開頭引擎收錄。 com/bGFURgAt。雖然差不多一樣 –
- 1. RouteCollection.php中的MethodNotAllowedHttpException行218:Laravel
- 2. Laravel錯誤:RouteCollection.php中的MethodNotAllowedHttpException行218
- 3. methodnotallowedhttpexception在routecollection.php行218
- 4. MethodNotAllowedHttpException在RouteCollection.php行218:
- 5. laravel 5.3 MethodNotAllowedHttpException在RouteCollection.php線218:
- 6. RouteCollection.php中的MethodNotAllowedHttpException行218 Laravel 5.2
- 7. RouteCollection.php中的MethodNotAllowedHttpException行218:laravel 5.4
- 8. RouteCollection.php中的MethodNotAllowedHttpException行218
- 9. MethodNotAllowedHttpException在RouteCollection.php行218:4
- 10. Laravel的XMLHttpRequest MethodNotAllowedHttpException在RouteCollection.php線218:
- 11. RouteCollection.php中的MethodNotAllowedHttpException在laravel中發生錯誤218錯誤
- 12. MethodNotAllowedHttpException在RouteCollection.php行218:試圖提交數據
- 13. RouteCollection.php中的MethodNotAllowedHttpException第218行Laravel 5.1使用Knockout js和Ajax
- 14. Laravel。 RouteCollection.php中的MethodNotAllowedHttpException
- 15. MethodNotAllowedHttpException在RouteCollection.php - laravel
- 16. Laravel MethodNotAllowedHttpException RouteCollection.php 233行:
- 17. RouteCollection.php中的MethodNotAllowedHttpException第218行我該怎麼辦?
- 18. Laravel 5 MethodNotAllowedHttpException RouteCollection.php 219行:
- 19. Laravel API MethodNotAllowedHttpException RouteCollection.php第233行
- 20. laravel 5.4 RouteCollection.php中的MethodNotAllowedHttpException(第251行)
- 21. Laravel 5:RouteCollection.php中的MethodNotAllowedHttpException行219
- 22. Laravel 5.2:RouteCollection.php中的MethodNotAllowedHttpException行219
- 23. MethodNotAllowedHttpException在RouteCollection.php在Laravel 5
- 24. Laravel 5.1.26:MethodNotAllowedHttpException在RouteCollection.php線219
- 25. Laravel 5.3搜索MethodNotAllowedHttpException 218:
- 26. Laravel錯誤:MethodNotAllowedHttpException在RouteCollection.php線233
- 27. MethodNotAllowedHttpException在RouteCollection.php行251:
- 28. 提交表單給出了MethodNotAllowedHttpException錯誤
- 29. Laravel 5.3 MethodNotAllowedHttpException在RouteCollection.php時嘗試後
- 30. RouteCollection.php中的MethodNotAllowedHttpException行251
你可能會在發送數據爲'GET'當它應該是'POST'。向我們展示如何製作AJAX調用以及它應該擊中的路線定義。 – ceejayoz
那就是:https://pastebin.com/WdVLfFa4 –
那麼,你發佈到'後/ store',但你有沒有'交/ store'路線。 – ceejayoz