Reputation: 6789
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";
?>
Upvotes: -1
Views: 154
Reputation: 17427
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
Upvotes: -1
Reputation: 697
You can use like below code.
$.ajax({
type: "POST",
url: "country.php",
data: "name=value",
success: function(data){
$("#suggestions").html(data);
}
});
Upvotes: 0
Reputation: 24052
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.
Upvotes: -1
Reputation: 50966
$.post
not
#.post
it will work.
if you're working with jquery
$.post("country.php", {countryPart:value}, function(data){
$("#suggestions").html(data);
});
Upvotes: 1