2012-11-17 30 views
0

可能重複:
$ not defined in JavaScript這個javascript ajax代碼有什麼問題?

螢火告訴我:

ReferenceError: $ is not defined [Break On This Error]

>$.ajax({

但我不確定爲什麼,或者我該如何糾正這個問題?

這應該是從Facebook的身份驗證寫入數據到一個URL或一些東西,以便我可以稍後用Java檢索它。

<script> 
     function login() { 
      FB.login(function(response) { 
       if (response.authResponse) { 
        // connected 
        console.log((response)); 
        console.log((response.session)); 
        $.ajax({ 
         url: "fbReceiver.html", 
         data: response, 
         type: "POST", 
         success: function() {} 
        }); 

       } else { 
        // cancelled 
       } 
      }); 
     } 
</script> 
+2

你肯定是正確加載jQuery的? – elclanrs

+0

是jquery.js內置的?在$(document).ready(function(){...})加載這個ajax;也許? – Mic

+0

Javascript!= jQuery。你忘了包含jQuery庫。 – Christoph

回答

3

確保jQuery的文件上面加載你這裏的代碼。

<script src="jQuery file here"></script> 

<script> your code here <script> 

你可以得到的jQuery的URL文件在這裏:http://jquery.com/

+0

謝謝:),第一次與jQuery在這裏定時器,我肯定錯過了 –