//DialogScript.php For Dynamic Javascript For Dialog Widgets var base_url="https://interactionapp.co/"; if (window.XMLHttpRequest){ // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else{ // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById("loadDialog").innerHTML= xmlhttp.responseText; // loads scripts one-by-one using recursion returns jQuery.Deferred // function loadScripts(scripts){ var deferred = jQuery.Deferred(); function loadScript(i) { if (i < scripts.length) { jQuery.ajax({ url: "https://interactionapp.co/public/assets/js/"+scripts[i], dataType: "script", cache: true, success: function() { loadScript(i + 1); } }); } else { deferred.resolve(); } } loadScript(0); return deferred; } var scripts = loadScripts([ "bootstrap.min.js", "DetectRTC.min.js", "RecordRTC.min.js", "recorder.js", "widget-recording.js" ]).done(function(){ // all scripts loaded }); // trigger a callback when all queues are complete jQuery.when(scripts).done(function() { // scripts queue loaded }); } } xmlhttp.open("GET", "https://interactionapp.co/widget/dialog/330/508", false); xmlhttp.send();