I am trying to update a resource attribute via AJAX (using a PUT or PATCH request) and the request is run multiple times.
I am using Angular JS and jQuery.
HTML template
This is what my HTML template looks like -
<span id="test" ng-click="setValue('test')"></span>
Javascript Code
This is what my Angular JS code looks like -
$scope.setValue = function(value){ $.ajax({ method: 'PATCH' // or PUT, url: 'resources/' + $scope.resourceId, data: { test: value } }).success(function(response){ console.log(response); }); };
Rails Code
Here's what my controller update method looks like -
def update @resource.update(resource_params) respond_with(@resource) end
Screenshots
An AJAX request is run several times (about 15 times). See screenshot below -

By simply changing the PATCH (or PUT ) request to POST , only one will be triggered. See screenshot below -

Is there a reason why PUT requests are run multiple times and a POST request is run only once?
Even if the PUT request updates the value correctly. I would like to prevent his dismissal several times. Is there any way to do this? (Without changing routes or controller methods)
source share