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 9235129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:57:12+00:00 2026-06-18T06:57:12+00:00

I change the autocomplete data source to my php file, and I have tried

  • 0

I change the autocomplete data source to my php file, and I have tried the code below. But it’s not work, could someone suggest how to fix it?

Thanks

$('#search').autocomplete({
    source: function( request, response ) {
        $.ajax({
            url: "/property_bldg.php",
            dataType: "jsonp",
            data: {
                query: request.term
            },
            success: function( data ) {
                response( $.map( data.suggestions, function( item ) {
                    return {
                        label: item.text,
                        value: item.text
                    }
                }));
            }
        });
    },
    minLength: 1
})

Return

{query:'A',par1:'',suggestions:['AUSTIN RD','ARCH','ARGYLE ST','AMOY GDN','ARIA','AQUAMARINE','ACADEMIC TERR','APEX','ALLWAY GDN','AP LEI CHAU DRIVE'],data:[]}

Updated:

$('#autocomplete_propSearch').autocomplete({
    source: function( request, response ) {
        $.ajax({
            url: "/property_bldg.php",
            dataType: "json",
            data: {
                query: request.term
            },
            complete: function (xhr, status) {
                if (status === 'error' || !xhr.responseText) {
                    alert('Error')
                }
                else {

                    response( $.map( xhr.responseText.suggestions, function( item ) {
                        return {
                            label: item,
                            value: item
                        }
                    }));
                }
            }
        });
    },
    minLength: 1
})
  • 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-06-18T06:57:13+00:00Added an answer on June 18, 2026 at 6:57 am

    You’re iterating over an array of strings, but trying to access the text property of them. Change your map body to:

                    return {
                        label: item,
                        value: item
                    }
    

    Working example at jsFiddle. If that doesn’t work for you, check whether the ajax call really completed successfully (by printing data to console, for instance).

    Update: if your server is returning exactly what you posted, then it’s not a valid JSONP response. See this tutorial and the jQuery docs for the proper way of doing JSONP (though, if you’re querying the same domain that served the page, it’s simpler – and safer – to use json instead).

    For instance, if your server is receiving the query:

    http://127.0.0.1:8080/property_bldg.php?callback=jQuery161006659467399874042_13‌​59964924178&query=a&_=1359964930143
    

    The correct response should be:

    jQuery161006659467399874042_13‌​59964924178({query:'A',par1:'',suggestions:['AUSTIN RD','ARCH','ARGYLE ST','AMOY GDN','ARIA','AQUAMARINE','ACADEMIC TERR','APEX','ALLWAY GDN','AP LEI CHAU DRIVE'],data:[]});
    

    And its content-type should be text/javascript (not application/json). You can customize that if you want, read the docs for more info.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code below is part of an autocomplete input created using JQuery UI. But
I have implemented the jquery autocomplete combobox, however the change event does not seem
I've got a requirement which I have to implement autocomplete, but I'm not sure
In the code below, I have the same function on three different events (focus,
I am using jQuery autocomplete which is working fine with existing element but not
I have realised that for my autocomplete I don't really need to work with
I have a working autocomplete text box fetching data from mysql server through a
I am trying to setup my Jquery UI autocomplete field to have data from
I have a jQuery autocomplete fild which gets existing data from my MVC action.
I have a jQuery autocomplete field with this code: var tags = [a, ab,

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.