I'm trying to get a jQuery script to load in an external JavaScript file based on if a cookie which I created exists, and it's doing weird things. It is either blanking the entire page and ONLY including my script, or just flat out not working at all.
This is what I have - any help would be tremendously appreciated:
I tried it with only $.getScript instead, and what it did, was loaded my file, but replaced the entire HTML of my page with it at runtime instead of appending the script to the html file.
I've been googling this to death, LOL and just can't get it figured out.
<script>
if($.cookie("so-affiliate") ) {
$().ready(function() {
// load the CJ file
$('#cj-placeholder').append("TEST<script type='text/javascript'>" + "$.getScript('/v/js/cjscript.js');" + "</" + "script>");
});
}else{
$('#cj-placeholder').append(".");
}
</script>