2011-04-07 68 views
1

我是一個完整的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

嘗試將url硬編碼到$ .getScript中(在此粘貼警報url);並查看該URL是否是有效的路徑。 – nolabel 2011-04-07 21:14:44

回答

0

解決了它......我安裝了FireQuery以使調試更容易。原來它損壞了實際的jquery腳本。

刪除它,現在它工作得很好。

0

以任何機會,您在不同的領域努力getScript加入()?即Rails應用程序正在運行http://www.foo.com/,並且您正在嘗試getScript(「http://www.bar.com/...」)?您不應該能夠跨域創建Ajax請求。

聽起來很像getScript()失敗。

+0

nope,所有的文件都在我的本地機器上,因此所有的文件都通過本地主機訪問atm – DeX3 2011-04-07 22:44:17

+0

您是否嘗試對路徑進行硬編碼,如@nolabel推薦的? – jdc 2011-04-08 17:31:00