When I run this, it sends two requests for some reason. When I remove the headers
object though it only runs once. Why is it running twice with the headers object?
$.ajax({
type: "get",
headers: {
Time: time
},
url: getHost() + "/leaderboard/top?gameId=" + gameId + "&token=" + createToken([gameId, time]),
dataType: "json",
complete: function(data){
showOutput(JSON.parse(data.responseText));
}
});
When I look in the chrome network inspector, I see that under Method
one says GET
and the other says OPTIONS
. Other than that the request is exactly the same.
On the server I have the following headers set:
this.res.setHeader("Content-Type", "text/json; charset=utf-8");
this.res.setHeader("Access-Control-Allow-Origin", "*");
this.res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Time");