Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7572205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:52:02+00:00 2026-05-30T15:52:02+00:00

I need help with this, I can’t see where is the problem. When I

  • 0

I need help with this, I can’t see where is the problem.

When I set source for autocomplete in html file, it works fine, when I same source or database values print out in ajax.php and return it via ajax it doesn’t work. What could be the problem? Help please.

Html :

    <!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Auto complete</title>
        <script type="text/javascript" src="jquery-1.7.1.min.js"></script>
        <script type="text/javascript" src="jquery-ui-1.8.18.custom.min.js"></script>
        <link rel="stylesheet" media="all" type="text/css" href="jquery-ui-1.8.custom.css" />
        <style type="text/css">
            .ui-autocomplete-loading {
                background: url("images/loader.gif") no-repeat scroll right center white;
            }
        </style>
        <script type="text/javascript">
            jQuery(document).ready(function($){                       
                $("#ac").autocomplete({
                    minLength: 2,
                    //source: [{"value":"Some Name","id":1},{"value":"Some Othername","id":2}]
                    source: function( request, response){
                        $.ajax({
                            type: 'GET',
                            url: 'ajax.php',
                            data: {
                                'term':request.term
                            },
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function(data){
                                console.log('Success : ' + data);
                            },
                            error: function(message){
                                alert(message);
                            }
                        });
                    },
                    select: function( event, ui ) {
                    }
                });
            });
        </script>
    </head>
    <body>
        <input type="text" id="ac" name="ac" size="100" />
    </body>
</html>

and my ajax.php file:

$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'test_db';

$server = mysql_connect($dbhost, $dbuser, $dbpass);
$connection = mysql_select_db($dbname, $server);

$term = $_GET['term'];

$qstring = "SELECT user_id,tName FROM `csv_data` WHERE tName LIKE '%" . $term . "%'";
$result = mysql_query($qstring);

$return_arr = array();

$i = 0;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {//loop through the retrieved values
    $row_a = array();
    if ($row['tName'] != null) {
        $i++;
        $row_a['value'] = ($row['tName']);
        $row_a['id'] = (int) $i;
        array_push($return_arr, $row_a);
    }
}

mysql_close($server);

header("Content-type: text/x-json");

/*$my_arr = array(
    array("value" => "Some Name", "id" => 1),
    array("value" => "Some Othername", "id" => 2)
);*/

//echo json_encode($return_arr);
print json_encode($return_arr);

//print json_encode($my_arr);

This is response from firebug(generated from database).

[{"value":"4 erste Spiele","id":1},{"value":"Meine ersten Spiele \"Blinde Kuh\"","id":2},{"value":"4 erste Spiele","id":3},{"value":"Meine ersten Spiele \"Blinde Kuh\"","id":4},{"value":"4 erste Spiele","id":5},{"value":"Meine ersten Spiele \"Blinde Kuh\"","id":6},{"value":"Maxi Kleine Spielewelt","id":7}]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:52:03+00:00Added an answer on May 30, 2026 at 3:52 pm

    The parameter response is actually a callback tthat you have to call – passing it your data – to display the result popup menu. Simply call it in the “success” callback:

    source: function(request, response) {
        $.ajax({
            ...
            success: function(data) {
                // pass your data to the response callback
                response(data);
            },
            error: function(message) {
                // pass an empty array to close the menu if it was initially opened
                response([]);
            }
        });
    },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need help with this error. Can't see what's wrong. Error: Warning: mysql_query() expects parameter
i need help with this problem... I have two lists of same objects SearchResult,
I need help, how can I learn this framework? Here's what I need to
can someone help with this? I need the following function to do this... $x
can any body help me on separating this example of data that i need
I need some drawings in my tableview. How can i do this. Any help
I need some help on this on how can I animate the following: If
I need help in this matter: We have a template of Excel file in
I need some help with this please I can't get a handle on it.
I really need help getting this query right. I can't share actual table and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.