var adServingCookieURL = "//wlkwiff.adsrv.eacdn.com/AdServingData/CookieData.ashx?Priority=last&Check=Clicks"; CrossDomainServiceCaller(adServingCookieURL, {}, true, SetAdServingReferralCookie); function SetAdServingReferralCookie(data) { jQuery("#AdServingReferralBTAG").appendTo("#registrationform"); jQuery("#AdServingReferralBTAG").val(data.btag); } function CrossDomainServiceCaller(URL, PostData, Async, AsyncCallback) { var xmlHttp = null; if (window.XMLHttpRequest) { // FireFox, Safari, etc. xmlHttp = new XMLHttpRequest(); try { xmlHttp.overrideMimeType('text/plain'); // Or anything else } catch (err) { } } else if (window.ActiveXObject) { // MSIE xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else { xmlHttp = new XMLHttpRequest(); } //do not let it be async if redirect is triggered. if (Async == null) { Async = false; } xmlHttp.withCredentials = true; if (Async) { xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState == 4 && xmlHttp.status == 200) { AsyncCallback(jQuery.parseJSON(xmlHttp.responseText)); } } } xmlHttp.open('POST', URL, Async); if (PostData != null) { var formString = ""; for (var key in PostData) { if (PostData.hasOwnProperty(key)) { formString += key + "=" + encodeURIComp(PostData[key]) + "&"; } } xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlHttp.send(formString); } else { xmlHttp.send(); } if (!Async && xmlHttp.status == 200) { return xmlHttp.responseText; } }