Angular js code
$scope.removeItemFromCart = function (productId) {
$http.put("removeItem/"+productId).success(function() {
alert("Item Removed");
$scope.refreshCartItems();
}).error(function(){
alert("Error");
$scope.refreshCartItems();
});
};
Rest controller
@RequestMapping(value = "/removeItem/{productId}", method = RequestMethod.PUT)
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void removeItem (@PathVariable("productId") int productId) {
System.out.println("Deleting item Id: "+productId);
CartItem cartItem = cartItemService.getCartItemByItemId(productId);
cartItemService.removeCartItem(cartItem);
}
Following is my code for removing an item from my cart. the problem is when i click on remove button in my cart it removes the item but it doesnt enter the success function in my $http.put().success rather show me the error message in the error function of my $http.put().error these functions are in my angular controller. CAn someone tell me what is the problem and where is my error?