From 6b2aa812e3b1408601a163d7032f9b8d945c8e7a Mon Sep 17 00:00:00 2001 From: "Matthew B. Jones" Date: Tue, 18 Mar 2014 14:58:11 -0400 Subject: [PATCH] Fix for MSIE9 doing CORS to HTTPS endpoint. --- blitline_cors.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/blitline_cors.js b/blitline_cors.js index acbe85b..10a05e8 100644 --- a/blitline_cors.js +++ b/blitline_cors.js @@ -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 = [], @@ -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.