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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:05:17+00:00 2026-05-23T22:05:17+00:00

Hi I am trying to implement a autocomplete field using Zend Jquery. I followed

  • 0

Hi I am trying to implement a autocomplete field using Zend Jquery. I followed a tutorial to grab the data from an array and I have extended the code to access the data from my mysql table.

IndexController.php

$this->view->autocompleteElement = new ZendX_JQuery_Form_Element_AutoComplete('ac');
    $this->view->autocompleteElement->setLabel('Autocomplete');
    $this->view->autocompleteElement->setJQueryParam('source', '/index/city');

This calls the cityAction()

public function cityAction()
{
    $results = Application_Model_City::search($this->_getParam('term'));
    $this->_helper->json(array_values($results));        
}

I then call the Model City

public static function search($term)
{
   $region = new Application_Model_DbTable_Regions();

   $results = $region->getRegion($term);

   return $results;

}

And finally the Regions db model

public function getRegion($term)
{

    $select = $this->select()->from($this,'City')
                                 ->where('City LIKE ? ',$term.'%');


    return $this->fetchAll($select)->toArray();

}

Now when I go the autocomplete field it shows the results but as UNDEFINED , I think its something to do the way I am send the data back to the json helper.

I used firebug and I can see the data is been pulled in the following format.

[{“City”:”London”},{“City”:”Londonderry”},{“City”:”Longfield”},{“City”:”Longhope”},{“City”:”Longniddry”}]

I think this format is incorrect, please any body dealt with this before?

Cheers

J

  • 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-23T22:05:18+00:00Added an answer on May 23, 2026 at 10:05 pm

    The ZendX_JQuery_Form_Element_AutoComplete element is a proxy to the AutoComplete View Helper, which is a proxy to the jQuery UI Autocomplete widget.

    If you read the overview on the jQuery UI Autocomplete page, you will note:

    The local data can be a simple Array of Strings, or it contains Objects for each item in the array, with either a label or value property or both. The label property is displayed in the suggestion menu. The value will be inserted into the input element after the user selected something from the menu. If just one property is specified, it will be used for both, eg. if you provide only value-properties, the value will also be used as the label.

    When a String is used, the Autocomplete plugin expects that string to point to a URL resource that will return JSON data. It can be on the same host or on a different one (must provide JSONP). The request parameter "term" gets added to that URL. The data itself can be in the same format as the local data described above.

    So, the JSON you are returning to the autocomplete should be structured more like:

    [{"label":"London","value":"London"},{"label":"Londonderry","value":"Londonderry"},{"label":"Longfield","value":"Longfield"}]
    

    Good luck!

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

Sidebar

Related Questions

I am trying to implement caching using jQuery UI autocomplete. I am using jQuery
I am trying to implement the jQuery autocomplete plugin by receiving the data through
Im trying to implement an asp.net textbox using the jQuery UI Autocomplete widget http://jqueryui.com/demos/autocomplete/#remote
I am trying to implement eBay autosuggest in an opera extension using jQuery autocomplete.
I am using jQuery UI autocomplete and trying to implement the autoFocus option. The
i'm trying to implement the jquery autocomplete plugin. I've got it up and running,
I have the following problem. Background I'm trying to implement an autocomplete selector with
I am trying to implement SO style autocomplete. I am using this gem to
I'm trying to implement an autocomplete field. I want this autocomplete to retrieve the
Hi I have been trying to implement auto complete in my site from 2

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.