diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-09-15 16:13:06 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-09-15 16:13:06 +0400 |
commit | 3ba8453c121521586345f36258f99cd4e27b6a25 (patch) | |
tree | 2a5e3fc7609e493cb775401c39946f66771bcda8 /js | |
parent | 76cef69bee1727ca5a165810594476584e6bdd62 (diff) |
refs #4996 do not fallback to GET if POST fails otherwise we might track twice
Diffstat (limited to 'js')
-rw-r--r-- | js/piwik.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/js/piwik.js b/js/piwik.js index 5a9cddfa4b..46a31a0602 100644 --- a/js/piwik.js +++ b/js/piwik.js @@ -2424,7 +2424,11 @@ if (typeof Piwik !== 'object') { /* * POST request to Piwik server using XMLHttpRequest. */ - function sendXmlHttpRequest(request, callback) { + function sendXmlHttpRequest(request, callback, fallbackToGet) { + if (!isDefined(fallbackToGet) || null === fallbackToGet) { + fallbackToGet = true; + } + try { // we use the progid Microsoft.XMLHTTP because // IE5.5 included MSXML 2.5; the progid MSXML2.XMLHTTP @@ -2439,7 +2443,7 @@ if (typeof Piwik !== 'object') { // fallback on error xhr.onreadystatechange = function () { - if (this.readyState === 4 && !(this.status >= 200 && this.status < 300)) { + if (this.readyState === 4 && !(this.status >= 200 && this.status < 300) && fallbackToGet) { getImage(request, callback); } else { if (typeof callback === 'function') { callback(); } @@ -2450,8 +2454,10 @@ if (typeof Piwik !== 'object') { xhr.send(request); } catch (e) { - // fallback - getImage(request, callback); + if (fallbackToGet) { + // fallback + getImage(request, callback); + } } } @@ -2490,7 +2496,7 @@ if (typeof Piwik !== 'object') { var now = new Date(); var bulk = '{"requests":["?' + requests.join('","?') + '"]}'; - sendXmlHttpRequest(bulk); + sendXmlHttpRequest(bulk, null, false); expireDateTime = now.getTime() + delay; } |