I cannot get the results of a jquery autocomplete to show, although the php code returns json results. The jquery code is as follows:
$("#newName").autocomplete({
source: function(request, response) {
$.ajax({
url: root + "/assets/php/autocomplete.php",
dataType: "json",
data: {
term : request.term,
field : "name"
},
success: function(data) {
response(data);
}
});
});
The php code is:
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$row_array['value'] = $row[$field];
array_push($return_arr,$row_array);
}
echo json_encode($return_arr);
When checking the results in Firebug, I get a response such as:
[{"value":"jdoe"}]
However, I never see a list of suggestions showing in the html page. Any suggestions on what the problem is.
Thanks, AB
To solve the "$(...). autocomplete is not a function" jQuery error, make sure to load the jQuery library before loading the jQuery UI library. The libraries have to be loaded only once on the page, otherwise, the error is thrown.
If autocomplete dropdown is open, Esc press shoult perform its default action only (closing dropdown and cancelling selection). How to check if autocomplete dropdown was opened ? It can check for any autocomplete box was opened in document body.
The AutoComplete control is an extender control that provides AutoCompletion services to any edit control on the same form as the AutoComplete control. AutoCompletion can be defined as prompting you with probable matches during data entry.
I fixed the problem by adding to my master css file a z-index style for the autocomplete. Everything now works properly.
.ui-autocomplete {
z-index: 100;
}
I have the same problem. For me solution is to set z-index to higher value like this
.ui-autocomplete
{
position:absolute;
cursor:default;
z-index:1001 !important
}
Some elements hide autocomplete form. (in my app)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With