2013-08-22 26 views
2

我引用我的頭以下的jquery文件:jQuery Mobile的引用錯誤「一個是不確定的」

<link rel='stylesheet' href='$root/css/jquery.mobile-1.3.2.min.css'> 

<script type='text/javascript' src='$root/js/jquery.mobile-1.3.2.min.js'> 
</script> 

<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'> 
</script> 

我得到以下錯誤:

a is undefined 

錯誤引用整個的jQuery .mobile-1.3.2.min.js文件。

任何想法爲什麼會發生這種情況?

回答

4

該腳本的順序是錯誤的。也關閉link標籤。

jQuery mobile是在jQuery之後調用的。

這裏是CDN-hosted files

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" /> 
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> 
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script> 

從你的角度來看:

<link rel='stylesheet' href='$root/css/jquery.mobile-1.3.2.min.css'/> 
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'> 
</script> 
<script type='text/javascript' src='$root/js/jquery.mobile-1.3.2.min.js'> 
</script> 
+0

謝謝!這消除了錯誤。但是我的一半網站現在沒有加載。任何想法如何造成它可能? – user2699231

+0

@ user2699231很高興我能夠幫助你。我無法用這些信息來猜測。檢查控制檯是否有錯誤。 – Praveen

+0

控制檯上沒有錯誤。我甚至不知道爲什麼切換這些語句會干擾網站的任何其他功能(它們都不使用jQuery)。 – user2699231

4

您必須先包含JQuery,然後再包含JQuery Mobile。這是因爲JQuery Mobile正在使用JQuery,並且當您首先包含JQuery Mobile時,它會查找JQuery功能,這些功能在此階段不會包括在內。

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.1/jquery.mobile-1.2.1.min.css" /> 
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script> 
<script src="http://code.jquery.com/mobile/1.2.1/jquery.mobile-1.2.1.min.js"></script> 
相關問題