// Wait until dom is ready... $( document ).ready(function() { updateBanner = function(){ // syntax is /invoke/// // where target is one of : dev | test | prod // clientname is default "client" // rulename is what is specified in the ui when publishing the rule var bannercheck = $.post(ddeLoc + "getbanner", '{"sessionid":"' + getSessionId() + '"}') .done( function(dataReturned){ // I'm expecting a json message returned identical to the dataToSend. // jQuery will autoconvert this to an object, so I can get the parameters out directly... // TODO - update the banner image with code returned from here, instead of just showing it on the page // $( ".result" ).text( dataReturned.bannercode ); $( ".showbannercode" ).text( dataReturned.bannercode ); $(".banner").hide(); var bannertoshow = $("#"+dataReturned.bannercode); if (bannertoshow.length == 0){ $("#DEFAULT").show(); } bannertoshow.show(); console.log("Bannercode: " + dataReturned.bannercode) }) .error(function(XMLHttpRequest, textStatus, errorThrown){ if (console.log){ console.log("DRE call failed: " + textStatus + " / " + errorThrown) } }) } // Make an initial call updateBanner(); // And re-check what the banner should be every 2 seconds - so we can respond to actions // that happen in another system such as the IVR. // setInterval(updateBanner, 2000) });