my config:
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/ajax/create', {
templateUrl: 'view/pagination/pagination.html',
controller: 'AjaxCtrl'
});
$routeProvider.when('/ajax/update/:id', {
templateUrl: 'view/pagination/pagination.html',
controller: 'AjaxCtrl'
});
$routeProvider.when('/ajax/delete/:id', {
templateUrl: 'view/pagination/pagination.html',
controller: 'AjaxCtrl'
});
}])
my code process:
$scope.doEdit = function(item) {
var notice = "Item #" + item.id + " has been edited with amount: " + item.amount;
$http.put('/ajax/update/' + item.id).then(function(data) {
alert(notice);
});
}
I'm trying all method put, delete
all of them have error without method get althought it still working
error in console
a 405 Method Not Allowed
indicates that the user agent (the web browser, in most cases) has requested a valid resource using an invalid HTTP method. This could happen in a few different circumstances:
So look into your server which HTTP method the API supports.
add this nginx.conf
add_header Allow "GET, POST, HEAD, PUT" always;
if ( $request_method !~ ^(GET|POST|HEAD|PUT)$ ) {
return 405;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.