Trying to implement an autocomplete box ultimately. For now im following php academy's lead. I just want to echo out "suggestions go here" underneath the input area when anything is entered. I have to files. home.php
and country.php
. home
contains the input part and country.php
just prints the dummy suggestion text. Right now when I type in the input area ..nothing happens. I am using jquery v 1.6.2
( jquery-1.6.2.min.js
)
home.php
is:
<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
is
<?php
echo "Suggestions Go Here";
?>
以前从未见过#.post ...尝试使用$ .post
$.post
not
#.post
it will work.
if you're working with jquery
$.post("country.php", {countryPart:value}, function(data){
$("#suggestions").html(data);
});
you wrote
#.post
should be
$.post
try that :)
You can use like below code.
$.ajax({
type: "POST",
url: "country.php",
data: "name=value",
success: function(data){
$("#suggestions").html(data);
}
});
If you're truly using JQuery, you need to change your post
call to this:
$.post("country.php", {countryPart:value}, function(data){
$("#suggestions").html(data);
});
You had #
instead of $
before the post
call.
应该是$.post
和#.post
The method name should be $
not #
you can use the "console of error"(ctrl + shift + j in monzilla firefox) for check error in javascript/HTML execution
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.