我是一个完整的jquery新手,但我正在关注this tutorial here让我开始。
我已经把它全部工作了,但是(我甚至不知道我做了什么)现在一切都在下降......
这是片段(见评论):
$( function() {
//This one here works and gets executed after the page has loaded
$.getScript( "some link copied from one of the actual hrefs" );
//Handler for some links that should load some js from the server and execute it
$( '#searchresults .pagination a' ).live( 'click',
function( event ) {
//This shows the correct link:
alert( this.href );
//However, this one doesn't even send a request:
$.getScript( this.href );
return false;
} );
} );
我正在使用JQuery 1.5.2。
另外值得注意的是:我已经安装了FireQuery用于调试目的,每次加载网站时它都会用“jQuery(...) called incorrectly
”来轰炸我。当我点击其中一个链接时,它会给我“When I called jQuery.get(...) with your args, an error was thrown! TypeError: rootjQuery is undefined
”。
看到我认为我的jquery.js文件可能已损坏,所以我刚刚下载并安装它。那里没有运气,但是......
任何帮助表示赞赏,thx
答案 0 :(得分:0)
您是否有机会尝试从其他域中获取脚本()?即Rails应用程序正在http://www.foo.com/上运行,您正在尝试使用getScript(“http://www.bar.com / ...”)?您不应该跨域提出Ajax请求。
听起来很像getScript()失败。
答案 1 :(得分:0)
解决了它......我安装了FireQuery以简化调试。原来它破坏了实际的jquery脚本。
删除它,现在它可以正常工作。