I couldn't find how to do this after digging through S\O. Im using javascript to create an iframe and then i'm loading jQuery into the Iframe. Now I just want to call methods such as $ajax in the Iframe context. Below is how i did it.
var iframe = document.createElement('iframe');
iframe.name = "loginFrame";
iframe.id = "loginFrame";
document.body.appendChild(iframe);
var idocument = iframe.contentWindow.document;
var jq = idocument.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
idocument.getElementsByTagName('body')[0].appendChild(jq);
jq.onload = function () {
}
This works and idocument
will in fact have the jQuery script in its body. Now using the Iframe, how would I make calls using jQuery?
idocument.$.ajax(url, settings)
Does not work and returns
Uncaught TypeError: Cannot read property 'ajax' of undefined
error. Any help is much appreciated?