So, I am calling a web service from jQuery using the .ajax method. The page that is calling the method is an HTTPS/SSL page, yet when the call is made, jQuery keeps making an HTTP request and it is failing because the server is set up to redirect all HTTP traffic to HTTPS...so a 301 error is coming back.
I have inspected my code a million times and tried a million ways to generate the url parameter for the ajax query. (using // for relative and now just appending the protocol https to the beginning of the url. Here is my javascript:
function add_inbound_record(serial_number, pass_fail_value)
{
pfv = pass_fail_value.toUpperCase();
url = location.protocol + // + location.hostname + /inbound/record- inspection/ + serial_number + / + pfv;
$.ajax({
url:url,
cache:false,
});
}
So, when this code executes, I check the url paramter in firebug and it shows up correctly with https and the URL properly formed. However, when I execute the ajax function I see this in firebug:
301 MOVED PERMANENTLY
192.168.1.9
20 B
192.168.1.9:443
Response Headersview source
Connection keep-alive
Content-Encoding gzip
Content-Length 20
Content-Type text/html; charset=utf-8
Date Wed, 24 Oct 2012 17:33:34 GMT
Location http://192.168.1.9/inbound/record-inspection/011234567890123421000000002995/P/?_=1351100020609
Server nginx/1.1.19
Vary Accept-Encoding
Request Headersview source
Accept */*
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Connection keep-alive
Cookie djdt=hide; csrftoken=sF9RUxrlS6IKURxOryH2d2yT05gMighn; sessionid=9682390da4011e445931643c81be9aae
Host 192.168.1.9
Referer https://192.168.1.9/fingerprint/inspect/
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:15.0) Gecko/20100101 Firefox/15.0.1
X-Requested-With XMLHttpRequest
As you can see above from the referrer, the protocol is HTTPS yet the location in the response header is HTTP? I can't for the life of me figure out why the request is going across the wire as HTTP and not HTTPS. The 301 response is accurate considering it is going as HTTP since, again, the webserver is configured to only allow HTTPS access. Any ideas?