Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>hey i found a way to add it....:)</p> <p>NOTE- this is a synchronous process so you dont have to worry about that the script is loaded or not.... the script will always load the instance u call the function and you can start using the loaded script instantaneously..</p> <p>lets use these 2 functions</p> <p>1) first one is the ajax function to retrieve the values where async should be true to send the request synchronously</p> <pre><code> // AJAX FUNCTION function loadXMLDoc(reqt,url,reqp,cfunc,async) { var xmlhttp; try// code for IE7+, Firefox, Chrome, Opera, Safari { xmlhttp=new XMLHttpRequest(); } catch(err)// code for IE6, IE5 { try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){ try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(E){} } } if(!xmlhttp) { alert("error"); } xmlhttp.onreadystatechange=function(){ if(xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { cfunc(xmlhttp.responseText); } } if(reqt=='GET') { url+=(reqp!=""?"?":"")+reqp; xmlhttp.open("GET",url,(async?false:true)); xmlhttp.send(); } else if(reqt=='POST') { xmlhttp.open("POST",url,(async?false:true)); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send(reqp); } else { return false; } } /*use this function loadXMLDoc(reqt,url,reqp,function(response){ }); */ </code></pre> <p>2)then we use ajax to load the js file as string and then append it to the new script tag's innerHTML and then append it to the head section and one more thing to ensure file is already loaded i used the id of script tag as the path to the file which makes it really easy task to check for the duplicate...:)</p> <pre><code> //add new script dynamically function add_script(src) { if(!document.getElementById(src)) { loadXMLDoc("GET",src,"",function(jsresp){ var head = document.getElementsByTagName("head")[0]; var script=document.createElement("script"); script.type='text/javascript'; script.id=src; script.text=jsresp; head.appendChild(script); },true); } } </code></pre> <p>thanks for all help i used to get and will get from this site and its users for the development purposes...</p> <p>regards VIPIN JAIN</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload