I am trying to load jQuery using xmlhttrequest object
I have following code:
loadDoc("https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js", myFunction1);
function loadDoc(url, cFunction) {
var xhttp;
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
cFunction(this);
}
};
xhttp.open("GET", url, true);
xhttp.send();
}
function myFunction1(xhttp) {
// action goes here
$(document).ready(function() {
alert('test');
});
}
I am getting the error:
(index):62 Uncaught ReferenceError: $ is not defined
at myFunction1 ((index):62)
at XMLHttpRequest.xhttp.onreadystatechange ((index):53)
at loadDoc ((index):57)
at window.onload ((index):46)
Any reason why this is happening?
I typically want to do it this way as I won't be able to use as I am within a CRM form.