我使用的是jQuery 1.10.2,在使用getScript时会出现以下错误。我加载jquery,然后调用包含此代码的JS文件。我甚至在调用jQuery之前对getScript版本使用警告,以便我知道它已经加载。
Uncaught TypeError: Cannot call method 'getScript' of undefined这是代码
$.noConflict();
jQuery(document).ready(function ($) {
load_scripts();
});
function pause_for_jquery(){
setTimeout(load_scripts, 50);
}
function load_scripts(){
if (!window.jQuery) {
pause_for_jquery();
}
else{
alert(jQuery.fn.jquery); //this alert works and displays '1.10.2'
$.getScript("url here", function() {});
}
}发布于 2014-01-15 00:00:36
$.noConflict();取消$对象。您将需要使用更长的jQuery()表单:
jQuery.getScript("url here", function() {});https://stackoverflow.com/questions/21126580
复制相似问题