3
我試圖更新採用了棱角分明的列表名稱。我需要使用哪種方法?放?當我做PUT的時候顯示405錯誤方法不允許,所以我做錯了什麼?
MY CODE
角
$scope.updatel = function($event){
console.log($event.keyCode);
if ($event.keyCode == 13) {
var list = {
name: $scope.editlist
};
$scope.editlist = '';
$http({
method: 'PUT',
url: 'http://localhost/anydo/anydocopy/anydocopy/public/lists/1',
data: list
})
.success(function() {
console.log('true');
$http({
method: 'GET',
url: 'http://localhost/anydocopy/public/lists'
})
.success(function (d) {
console.log(d);
$scope.listsdata = d;
});
})
.error(function() {
console.log('false');
});
}};
Laravel路線
Route::put('lists/{id}', '[email protected]');
Laravel控制器
public function update($id, CreateListsRequest $request)
{
$response['lists'] = Lists::findorfail($id)->update($request->all());
return Response($response, 201);
}
Larav埃爾中間件
class Cors
{
public function handle($request, Closure $next)
{
$response = $next($request);
$response->headers->set('Access-Control-Allow-Origin', '*');
$response->headers->set(
'Access-Control-Allow-Headers',
'Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, x-xsrf-token, X-Requested-With'
);
$response->headers->set('Access-Control-Allow-Credentials', 'true');
$response->headers->set('Access-Control-Allow-Methods', '*');
return $response;
}
}
HTML
<input type="text" id="edit" ng-model="editlist" ng-show="edbut.show" ng-keydown="updatel($event)" onkeydown="hideshow(document.getElementById('edit'))" class="form-control" style="font:24px bold;" value="{{lists.name}}" />
EDITED
現在我已經工作的網址,是的這是不對的。目前PUT方法仍然不起作用,並顯示500內部服務器錯誤。哪裏不對?似乎錯誤是TokenMismatchException in VerifyCsrfToken.php line 53:
是的,你是對的,但現在我有500內部服務器錯誤... –
而且我實際上不知道如何添加該調試點..我新laravel:D –
檢查錯誤日誌:tail -f storage/logs/laravel-2015-09-2.log 在您的項目根目錄下。檢查爲什麼給它500錯誤。 (假設你正在使用laravel 5) –