From efab481c004110be33bdb4f46c924b2cda7bd24f Mon Sep 17 00:00:00 2001 From: Justin Karneges Date: Thu, 31 Jan 2013 23:25:52 -0800 Subject: fixes --- polldance.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/polldance.js b/polldance.js index 4e08d3d..9623bc7 100644 --- a/polldance.js +++ b/polldance.js @@ -122,7 +122,7 @@ var DEBUG = true; return !a.hostname || (a.hostname == loc.hostname && a.port == loc.port && a.protocol == loc.protocol); }; - var chooseTransport = function (transportType) { + var chooseTransport = function (transportType, url) { var transport; if (transportType == transportTypes.Auto) { if (corsAvailable || sameOrigin(url)) { @@ -232,10 +232,10 @@ var DEBUG = true; return; } - self._method = method; - self._url = url; - self._headers = headers; - self._body = body; + this._method = method; + this._url = url; + this._headers = headers; + this._body = body; this._start(); }; Request.prototype._start = function() { @@ -294,17 +294,12 @@ var DEBUG = true; // Create a copy of the transport because we don't want // to give public access to it (changing it between now and // cleanout would be a no-no) - this._transport = chooseTransport(this.transport); + this._transport = chooseTransport(this.transport, url); if (this._transport == transportTypes.Xhr) { - this._xhr = this._xhr_start(method, url, headers, body); - consoleinfo("PD: xhr start"); - } else { // Jsonp - this._jsonp = this._jsonp_start(method, url, headers, body); - consoleinfo("PD: json-p start " + this._jsonp.id + " " + src); } }; Request.prototype.abort = function () { @@ -331,6 +326,8 @@ var DEBUG = true; xhr.send(body); + consoleinfo("PD: XHR start"); + return xhr; }; Request.prototype._xhr_cleanup = function(xhr, abort) { @@ -375,6 +372,8 @@ var DEBUG = true; jsonCallbacks.addJsonpCallback(jsonp.id, this); addJsonpScriptToDom(src, jsonp.scriptId); + consoleinfo("PD: json-p start " + jsonp.id + " " + src); + return jsonp; }; Request.prototype._jsonp_cleanup = function (jsonp, abort) { @@ -440,11 +439,11 @@ var DEBUG = true; this._timer = null; if (this._transport == transportTypes.Xhr) { - consoleinfo("PD: XHR canceled"); + consoleinfo("PD: XHR cleanup"); this._xhr_cleanup(this._xhr, abort); this._xhr = null; } else { // Jsonp - consoleinfo("PD: json-p " + this._jsonp.id + " canceled"); + consoleinfo("PD: json-p " + this._jsonp.id + " cleanup"); this._jsonp_cleanup(this._jsonp, abort); this._jsonp = null; } -- cgit v1.2.3