I load my jQuery and jQuery UI files dynamically. The jQuery file loads successfully but when the jQuery UI file loads an error occurs
The following is what is shown in the console : Uncaught TypeError: Cannot read property 'ui' of undefined
My code is given below
(function()
{
var jQuery;
if (window.jQuery === undefined)
{
var script_tag = document.createElement('script');
script_tag.setAttribute("type", "text/javascript");
script_tag.setAttribute("src",
"//code.jquery.com/jquery-1.11.0.min.js");
if (script_tag.readyState)
{
script_tag.onreadystatechange = function()
{
if (this.readyState === 'complete' || this.readyState === 'loaded')
{
scriptLoadHandler();
}
};
}
else
{
script_tag.onload = scriptLoadHandler;
}
(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
}
else
{
jQuery = window.jQuery;
main();
}
function scriptLoadHandler()
{
jQuery = window.jQuery.noConflict(true);
main();
}
function main() {
jQuery(document).ready(function($) {
jQuery.getScript('http://code.jquery.com/ui/1.11.1/jquery-ui.min.js', function() {
jQuery.noConflict(true);
});
};
})();
Can someone help me with this?
main()and thejQuery(document).ready...are not properly closed in your markup.