2013-03-25 103 views
-1

我有一個可能非常簡單的問題,完全欺騙我。鏈接JS沒有運行緩慢的網絡服務器

我有一個Web服務器(XAMPP)運行一個相當慢的USB棒。 我有一個非常簡單的文件結構:

--htdocs 
    --projects 
    --callback 
     index.html 
     --js 
      jquery-1.9.1.min.js 
      callbackclient.js 
     --css 
      main.css 

出於某種原因,我不能讓一個簡單的鏈接的腳本工作: 這裏是我的index.html

<!DOCTYPE HTML> 
<html> 
    <head> 
    <script src='js/jquery-1.9.1.min.js' type='text/javascript'></script> 
    <script src='js/callbackclient.js' type='text/javacsript'></script> 
    <link href='css/main.css' rel='stylesheet' type='text/css'> 
    </head> 
    <body> 
    This is a test 
    </body> 
    <script> 
    $(document).ready(function(){ 
     tester(); 
    }); 
    </script> 
</html> 

這是我的callbackclient.js:
function tester(){ console.log("test"); }

當我打localhost/projects/callback瀏覽器顯示「這是一個測試」的預期,但我在控制檯得到一個錯誤:

Uncaught ReferenceError: tester is not defined

我得到同樣的,如果我嘗試運行測試儀();從控制檯直接,但$("head")正確選擇頭元素,我猜是意味着jQuery正在加載罰款。

我一定錯過了一些根本 - 有人請賜教!

回答

2

可能是您拼寫腳本標記的類型。的text/javacsript代替text/javascript

+0

這很可能。我將在明天再次查看我的開發PC並接受答案!我知道這將是愚蠢的! – 2013-03-25 23:26:23

0

試試這個你callbackClient.js內:

var tester = function(){ console.log("test"); } 

如果成功,你只需要具備的功能被設置爲一個變量,然後調用它。如果還是不行,那我就直接刪除JS代碼的HTML網頁上,並做到這一點你callbackClient.js內:

jQuery(function() { 
    // Logic here 
    console.log('this is working, right?'); 

    var functionName = function() { 
     console.log('blah blah blah') 
    } 

    functionName(); 
}) 

希望幫助!