var async = async || [];
(function () {
var done = false;
var script = document.createElement("script"),
head = document.getElementsByTagName("head")[0] || document.documentElement;
script.src = '<?=HTML_ROOT?>js/jquery.js';
script.type = 'text/javascript';
script.async = true;
script.onload = script.onreadystatechange = function() {
if (!done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) {
done = true;
console.log('jquery main script is ready');
// Process async variable
//var async = async || [];
while(async.length) { // there is some syncing to be done
var obj = async.shift();
if (obj[0] =="ready") {
$(obj[1]);
}else if (obj[0] =="load"){
$(window).load(obj[1]);
}
}
async = {
push: function(param){
if (param[0] =="ready") {
$(param[1]);
}else if (param[0] =="load"){
$(window).load(param[1]);
}
}
};
// End of processing
script.onload = script.onreadystatechange = null;
if (head && script.parentNode) {
head.removeChild(script);
}
}
};
head.insertBefore(script, head.firstChild);
})();
foutmelding
nl:2172 Uncaught TypeError: $ is not a function
at HTMLScriptElement.script.onload.script.onreadystatechange (nl:2172)
script.onload.script.onreadystatechange @ nl:2172
regel 2172: $(obj[1]);
wat is hier fout aan? De url klopt gewoon , die kan ik openen.
nl:2172 Uncaught TypeError: $ is not a function
at HTMLScriptElement.script.onload.script.onreadystatechange (nl:2172)
script.onload.script.onreadystatechange @ nl:2172
regel 2172: $(obj[1]);
Als ik $( naar jQuery( verander doet hij het wel, maar waarom?
precies zoals ik de code gepost heb met nu $( naar jQuery( veranderd. Maar hij komt toch niet verder zonder debug foutmeldingen. Hij laad niet alle bestanden, terwijl als ik hem zonder asynchronisch laden, hij wel alles goed pakt.
Jij laadt dus twee keer een Jquery library in? not good, volgens mij heb je die code zelf in de jquery .ready() functie geplakt maar dat gaat in dit geval natuurlijk niet werken.