2010-12-14 85 views
0

我無法弄清楚爲什麼會發生這種情況。Javascript錯誤,請幫助

http://www.freemoviedb.com/watch/5749/28_weeks_later.html 

單擊拇指向上/拇指向下,它不會做任何事情,但加載。

在Firebug,所有它說的是:

invalid 'in' operand a 
http://static.freemoviedb.com/thumbsup/init.min.js.php 
Line 1 

/

invalid 'in' operand a 
error(Object { name="a"})init.min.js.php (line 1) 
b()jquery.min.js (line 124) 
abort(Object { name="q"}) 
+0

你的代碼在哪裏? – SilentGhost 2010-12-14 17:44:38

+0

代碼被縮小。在試圖調試之前,先獲取一個未經修改的版本。這種方式的行號會更有用。 – Quentin 2010-12-14 17:46:16

回答

3

它打破是響應的原因,是因爲它被另一個域的,是null(感謝same origin policy),所以這部分:

success: function (a) { 
    if ('error' in a) { //here's your error 

...失敗,因爲從響應(a)的數據將null一個跨域請求,("anything" in null)將拋出你看到的錯誤。

+0

你建議我做什麼來解決這個問題? – Latox 2010-12-14 17:56:58

+0

@Kyle - 您的投票頁面需要位於同一個域名中,「www.freemoviedb.com」而不是static.freemoviedb.com,或者將其設爲JSONP請求,這是一個選項......儘管JSONP有一些安全問題,最好與相同的域名。 – 2010-12-14 18:01:46

+0

@Kyle - 你有'url:g +'init.php','...不管'g'在完整版本中,'g'是指'var g ='http://static.freemoviedb。 com/thumbsup /';',而不是在你的'url'中使用它,實際上在那裏使用'www.'域。 – 2010-12-14 18:04:21

2

我馬上看到的問題是,你的Ajax請求會跨域,它似乎會產生一個上述錯誤

XMLHttpRequest cannot load http://static.freemoviedb.com/thumbsup/init.php . Origin http://www.freemoviedb.com is not allowed by Access-Control-Allow-Origin.

www.xyz.com大於static.xyz.com

不同,這可能是爲什麼將其餘的代碼失敗

+0

因爲我只是將我的圖像,js和css改爲靜態無cookie的域名,我該如何解決這個問題? – Latox 2010-12-14 17:56:14

+0

我認爲這是在上述回答中回答的。祝你好運! – Dutchie432 2010-12-15 14:19:50