簡體   English   中英

使用文檔就緒語句時,jQuery停止工作

[英]jquery stops working when using document ready statement

因此我的代碼一直運行良好。 但是,一旦我在文檔上准備好陳述,整個腳本就會停止工作。 我嘗試在文檔就緒功能中放置一個警報,它可以正確通過。

我真的不確定是什么問題,以及如何進行調試。 任何建議將不勝感激

JS code

$(document).ready(function() {
    $("#sample").effect("transfer", {
        to: $("#{{ $stimuli['sample'][0] }}")
    }, 7000, function() {

      $('#{{$stimuli['sample'][0]}}')
        .append('<a href="response/{{$stimuli['sample'][0]}}"><div class="ui-effects-transfer"></div></a>');

      $('#{{$stimuli['sample'][0]}}').css("border", "10px solid green");
    });

});

一些控制台消息:

    'webkitIndexedDB' is deprecated. Please use 'indexedDB' instead.
firebug-lite.js:15683 'Performance.onwebkitresourcetimingbufferfull' is deprecated. Please use 'Performance.onresourcetimingbufferfull' instead.
http://getfirebug.com/releases/lite/skin/xp/pixel_transparent.gif Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8888/pp/public/public/assets/css/media-queries.css Failed to load resource: the server responded with a status of 404 (Not Found)

新更新缺少一些錯誤。

Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8888/pp/public/task/matching/js/init.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8888/pp/public/public/assets/css/media-queries.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8888/pp/public/task/matching/js/modernizr.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8888/pp/public/task/matching/js/jquery-migrate-1.2.1.min.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8888/pp/public/task/matching/js/jquery.flexslider.js Failed to load resource: the server responded with a status of 404 (Not Found)
active:94 Uncaught TypeError: $(...).effect is not a function
firebug-lite.js:11883 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
chrome-extension://bmagokdooijbeehmkpknfglimnifench/firebug-lite.js Failed to load resource: the server responded with a status of 404 (Not Found)fetchResource @ firebug-lite.js:11884
firebug-lite.js:30396 'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead.
firebug-lite.js:30396 'webkitIndexedDB' is deprecated. Please use 'indexedDB' instead.
firebug-lite.js:15683 'Performance.onwebkitresourcetimingbufferfull' is deprecated. Please use 'Performance.onresourcetimingbufferfull' instead.
http://getfirebug.com/releases/lite/skin/xp/pixel_transparent.gif Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:8888/pp/public/public/assets/css/media-queries.css Failed to load resource: the server responded with a status of 404 (Not Found)

如果要動態創建任何HTML,則應使用.on而不是標准的.ready ,我不確定這是否可以解決您的問題,因為您提供的信息非常少,我不是100%出了什么問題。

還要確保<script src='jquery.js'></script>位於html頁面的底部。 這樣可以確保html首先加載javascript。 以下是.on('ready')的示例

$(document).on('ready', function() {
   // Put your code in here
});

編輯:

好吧,我想我可能知道你的問題,請確保您的JQUERY UI腳本被附加到文檔AFTER您的JQUERY 因此,例如,它看起來應該像這樣:

<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script src="YOUR_CUSTOM_SCRIPT_.JS"></script> <!-- Put your document.ready function here -->

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM