I have a javascript that needs to be loaded on the "completion" page of an ecommerce site, here is the code:
<script type="text/javascript">
var skulist="",pricelist="",quantitylist="";
for (var i=0; i < OrderDetails.length; i++){
skulist = OrderDetails[i][2]+","+skulist;
pricelist =OrderDetails[i][5]+","+pricelist;
quantitylist =OrderDetails[i][6]+","+quantitylist;
}
skulistLen=skulist.length;
skulist = skulist.slice(0,skulistLen-1);
pricelistLen=pricelist.length;
pricelist = pricelist.slice(0,pricelistLen-1);
quantitylistLen=quantitylist.length;
quantitylist = quantitylist.slice(0,quantitylistLen-1);
document.write("<iframe height='1' width='1' frameborder='0' scrolling='no' src='https://www.emjcd.com/tags/c?containerTagId=49296&ITEM1="+skulist+"&AMT1="+pricelist+"&QTY1="+quantitylist+"&CID=10000171&OID=$(OrderNo)&TYPE=362565438&CURRENCY=USD' name='cj_conversion'></iframe>");
</script>
and I need to call it with jquery... (for other reasons) - and I am doing so like this:
<div id="cj-placeholder"><!--placeholder--></div>
<script>
if($.cookie("so-affiliate") ) {
$().ready(function() {
// load external file
//$('#cj-placeholder').load('/v/js/cj.html', function() {
//return;
$.get('/v/js/cj.html')
.success(function(data) {
$('#cj-placeholder').html(data);
});
});
}else{
$('#cj-placeholder').append('.');
}
</script>
the problem is, when I do this, I get a blank page with ONLY the contents of cj.html inside (the script) - it is replacing the order finished page instead of appending to it... by searching here, I learned that if a document.write is called like this AFTER the page is loaded then it'll replace it as it is, problem is.... what do I do?
document.write()? Did you get that from w3schools?