Skip to content
This repository has been archived by the owner on Feb 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #10 in AOLP_ADS_JS/prebid.js from feature/re-enabl…
Browse files Browse the repository at this point in the history
…e_ajax_tracking_requests to master

* commit '0f92570fa8327bd504e9b05e9667ac225dfc16c4':
  Re-enable ajax tracking requests. Ensure that withCredentials flag is set.
  • Loading branch information
marian-r committed Aug 11, 2016
2 parents efaa904 + 0f92570 commit fc0c18f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/adapters/analytics/aol.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ export default utils.extend(adapter({
},

reportEvent(url) {
var pixel = new Image();
pixel.src = url;
ajax(url, null, null, null, {isTrackingRequest: true});
},

getBaseSchema(eventId, adUnit) {
Expand Down
13 changes: 10 additions & 3 deletions src/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
* @param callback object callback
* @param data mixed data
* @param x null Ajax request
* @param options.isTrackingRequest set to true to denote the request
* is for tracking purposes, as opposed to loading remote data.
*/

export const ajax = function ajax(url, callback, data, x = null) {
export const ajax = function ajax(url, callback, data, x = null,
options = {isTrackingRequest: false }) {
try {
if (window.XMLHttpRequest) {
x = new window.XMLHttpRequest('MSXML2.XMLHTTP.3.0');
Expand All @@ -22,8 +25,12 @@ export const ajax = function ajax(url, callback, data, x = null) {

//x = new (window.XMLHttpRequest || window.ActiveXObject)('MSXML2.XMLHTTP.3.0');
x.open(data ? 'POST' : 'GET', url, 1);
x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
x.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
if (options.isTrackingRequest) {
x.withCredentials = true;
} else {
x.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
x.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
}

//x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
x.onreadystatechange = function () {
Expand Down

0 comments on commit fc0c18f

Please sign in to comment.