Sunday 31 July 2016

jquery - Double HTTP call to server with different METHOD

My ex-colleague left some angular.js code to save some data to database via a HTTP POST.



factory.save=function(data){

var deferred=$q.defer();

$http({
url:'http://localhost/saveData',
method:"POST",
headers: {'Content-Type': 'application/json'},
data:data
}).success(function(result){
//success
deferred.resolve();

});

return deferred.promise;
}


When I exam the web traffic between the UI and API Server, I see the saveData API was called twice. The first call is using request method OPTIONS and the second one is POST as expected. I searched throughout the UI code and don't find any API call to saveData with method = OPTIONS. Is this something built in $http? How do I save this hit to the API server?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...