I’ve come across a very strange issue. The following jQuery receives an HTTP 405 error code and sends an OPTIONS request method instead of a GET.
function GetPerf()
{
jQuery.support.cors = true;
leInterval = setInterval(function()
{
$.ajax({
url: "http://localhost/PerfMon3/api/performance/categories",
data: { machine_name : "CLOUDMACHINE" },
type: "GET",
contentType: "application/json; charset=utf-8",
dataType: "json",
xhrFields: {
withCredentials: true
},
success: function (data) {
WriteResponse(data);
},
error: function (x, y, z) {
alert(data);
}
});
},
1000)
}
The interesting part is that this works perfectly fine in Internet Explorer, but Chrome I get a 405. Does anyone know what’s going on?
Additional note:
It works perfectly fine regardless of browser when running it from the browser with IIS where the application is hosted. This problem only comes into play from remote machines.
Well, I just love finding out the answer to the issue with my own testing right after asking it on SO. I’m sorry about that, guys.
I changed the url line in the jQuery to
and now it works perfectly fine.
Still, why did it originally work only in IE? It doesn’t make sense.