試圖最終實現一個自動完成框。現在即時下面的PHP學院的領導。當輸入任何內容時,我只想在輸入區域的下方迴應「建議去這裏」。我必須要文件。 home.php
和country.php
。 home
包含輸入部分和country.php
只是打印虛擬建議文本。現在當我輸入輸入區域時,沒有任何事情發生。我使用的jquery v 1.6.2
(jquery-1.6.2.min.js
)爲什麼這個JQuery/AJAX調用不起作用?
home.php
是:
<html>
<head>
<script type ="text/javascript" src ="jquery.js"></script>
<script type ="text/javascript">
function getSuggestions(value){
#.post("country.php", {countryPart:value}, function(data){
$("#suggestions").html(data);
});
}
</script>
</head>
<body>
<div id = "content_holder">
<input type = "text" name="country" value= "" id = "country" onkeyup="getSuggestions(this.value);" />
<div id ="suggestions"></div>
</div>
</body>
</html>
country.php
是
<?php
echo "Suggestions Go Here";
?>
你確定它是「#.post」而不是「$ .post」嗎? – Arief
一個錯字? '#.post'而不是'$ .post'?如果不是這種情況,ajax調用是否出現在Firebug上? –
我想念一個表單元素?這應該給不正確的HTML。不知道是否jQuery困擾,但它可以得到混亂... –