![](/img/trans.png)
[英]Why is my PHP script not being executed when calling it by AJAX JQuery?
[英]why is my jquery code not being executed?
在這里有點瘋狂,我想知道為什么一個簡單的
console.log("test")
沒有出現在我的控制台中。 我的代碼如下。 我也試過
$(function() {
console.log("test")
});
但這也沒有做到。 上面的功能和下面的功能的目的不是要等到頁面加載然后執行該功能嗎? 無論我將代碼放在哪里-標頭,正文...都無法正常工作。
<!DOCTYPE html>
<html>
<head>
<title>jQM Autocomplete</title>
<meta content="initial-scale=1, maximum-scale=1, user-scalable=0" name="viewport" />
<meta name="viewport" content="width=device-width" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<link rel="stylesheet" href="styles.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script src="jqm.autoComplete-1.5.2.js"></script>
<script src="code.js"></script>
</head>
<body>
<div data-role="page" id="mainPage">
<div data-role="content">
<p>
In this example autoComplete uses a local array comprised of strings. This also shows an example of the matchFromStart property set to false.
</p>
<p>
<input type="text" id="searchField" placeholder="Categories">
<ul id="suggestions" data-role="listview" data-inset="true"></ul>
</p>
</div>
</div>
<script>
$(document).on("pageshow", "mainPage", function() {
console.log("test")
});
</script>
</body>
</html>
在頁面之前,控制台已准備就緒,因此您不會通過使用document.ready回調獲得任何信息。 可能是某些東西已覆蓋您的控制台。 要確定是否正確,只需在控制台中鍵入console
即可檢查控制台對象。 在Chrome中,它應返回如下內容:
Console {memory: MemoryInfo, debug: function, error: function, info: function, log: function…}
如果證明是正確的,則需要找到在代碼中重新定義控制台的位置。 另外,您可能想在其他瀏覽器中測試代碼-也許您有擴展名或由於某種原因而阻塞了控制台。
但在進行所有操作之前,請仔細檢查您的代碼是否存在語法錯誤。
另外,請確保已將控制台設置為顯示日志(過濾器按鈕,它位於清除控制台按鈕旁邊)。
問題出在我的控制台設置上。 在控制台中,底部有一些灰色按鈕-全部,錯誤,警告,日志,調試。 好吧,由於某種原因選擇了錯誤。 所以我在控制台中什么也沒得到,只有錯誤。 單擊“全部”,它可以正常工作。
話雖如此,我的代碼也缺少在主頁之前的#號(以null突出顯示)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.