I am loading an ajax response, and I need jQuery for it to make sense. I cannot load jQuery on page load due to latency reasons.
So I want to be able to load javascipt/css, whenever this ajax call is made. I read a lot of articles on this, but nothing works for me in all browsers.
I tried putting these link/script tags in the javascript response and then eval'ing the javascript in output after some time(300ms), but that does not work in chrome.(Maybe some race condition).
I also tried this:
function addJquery() {
var script = document.createElement("script");
script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.setAttribute('type', 'text/javascript');
script.addEventListener('load', function() {
var script = document.createElement("script");
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
This works in Firefox, but does not work in Chrome. I am not sure what I am doing wrong here. Can some please help, in fixing this issue?