Load jQuery by javascript and run a function from another file -


i need load 3 jquery scripts in page. business reasons i've make minimum modifications possible i've decided create 1 javascript included in website.

after that, script must load jquery , 3 more jquery scripts besides 3 css files.

basically, until now, that's i've got:

var jquery = document.createelement('script'); jquery.type = "text/javascript"; jquery.src = "common/com/jquery/jquery-1.9.1.js"; document.getelementsbytagname('head')[0].appendchild(jquery,document.getelementsbytagname('head')[0].firstchild);  var prettyphoto = document.createelement('script'); prettyphoto.type = "text/javascript"; prettyphoto.src = "common/com/prettyphoto/jquery.prettyphoto.js"; document.getelementsbytagname('head')[0].appendchild(prettyphoto,document.getelementsbytagname('head')[0].firstchild);  var jqueryui = document.createelement('script'); jqueryui.type = "text/javascript"; jqueryui.src = "common/com/jqueryui/jquery-ui.js"; document.getelementsbytagname('head')[0].appendchild(jqueryui,document.getelementsbytagname('head')[0].firstchild);  var kohlerapp = document.createelement('script'); kohlerapp.type = "text/javascript"; kohlerapp.src = "common/js/lelak.js"; document.getelementsbytagname('head')[0].appendchild(kohlerapp,document.getelementsbytagname('head')[0].firstchild);  var style = document.createelement("link"); style.type = "text/css"; style.href = "common/css/style.css"; style.rel = "stylesheet"; document.getelementsbytagname('head')[0].appendchild(style,document.getelementsbytagname('head')[0].firstchild);  var jqueryui = document.createelement("link"); jqueryui.type = "text/css"; jqueryui.href = "common/css/jquery-ui.css"; jqueryui.rel = "stylesheet"; document.getelementsbytagname('head')[0].appendchild(jqueryui,document.getelementsbytagname('head')[0].firstchild);  var prettyphoto = document.createelement("link"); prettyphoto.type = "text/css"; prettyphoto.href = "common/css/prettyphoto.css"; prettyphoto.rel = "stylesheet"; document.getelementsbytagname('head')[0].appendchild(prettyphoto,document.getelementsbytagname('head')[0].firstchild);  lelakapp.giveerror("0","test"); 

i'm trying execute 1 of jquery functions contained in 1 of scripts included no success. returns following error:

uncaught referenceerror: lelakapp not defined  

(where lelakapp script)

how can load jquery , personal jquery script , load function personal script, together?


edit

i'm trying execute simple request of jquery using requirejs

define(["../com/jquery/jquery-1.9.1"], function($) { $('body').html(''); }); 

but i'm receiving error:

uncaught typeerror: undefined not function 

i think because dont know whether script has loaded or not @ time try use function.

you try adding onload event handler script tags , start using scripts once loaded.

take @ require.js either use or ideas : http://requirejs.org/

require(["helper/util"], function(util) {     //this function called when scripts/helper/util.js loaded.     //if util.js calls define(), function not fired until     //util's dependencies have loaded, , util argument hold     //the module value "helper/util". }); 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -