Skip to content

Commit

Permalink
Fix for MSIE9 doing CORS to HTTPS endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewbjones committed Mar 18, 2014
1 parent 313b4f8 commit 6b2aa81
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions blitline_cors.js
Expand Up @@ -5,8 +5,8 @@ Blitline = function() {
completedCallback,
inProgress = false,
images = [],
serverUrl = "http://api.blitline.com",
cacheUrl = "http://cache.blitline.com/listen/";
serverUrl = (window.location.protocol + "//api.blitline.com"),
cacheUrl = (window.location.protocol + "//cache.blitline.com/listen/");

this.submit = function(jobs, callbacks) {
var validationErrors = [],
Expand Down Expand Up @@ -165,23 +165,24 @@ Blitline = function() {
{
try {
// Try using jQuery to POST
jQuery.post(url, data, callback, type);
jQuery.post(url, data, callback, type).fail(function(){ throw "jQuery.post() failed"; });
} catch(e) {
// jQuery POST failed
var params = '';
var key;
for (key in data) {
params = params+'&'+key+'='+data[key];
params = params+'&'+key+'='+encodeURIComponent(data[key]);
}
// Try XDR, or use the proxy
if (jQuery.browser.msie && window.XDomainRequest) {
// Use XDR
var xdr = new XDomainRequest();
xdr.open("post", url);
xdr.send(params);
xdr.onprogress = function() {};
xdr.onload = function() {
callback(handleXDROnload(this, type), 'success', this);
};
xdr.send(params);
} else {
try {
// Use the proxy to post the data.
Expand Down

0 comments on commit 6b2aa81

Please sign in to comment.