Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autocomplete Not Showing Results That Are Returned

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

like image 901
anthony Avatar asked Feb 25 '13 14:02

anthony


People also ask

How do I fix autocomplete is not a function?

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.

How do I know if autocomplete dropdown is open?

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.

What is autocomplete control?

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.


2 Answers

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;
}
like image 172
anthony Avatar answered Oct 05 '22 16:10

anthony


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)

like image 37
Ramzes Avatar answered Oct 05 '22 14:10

Ramzes