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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:19:01+00:00 2026-06-12T07:19:01+00:00

The code below is part of an autocomplete input created using JQuery UI. But

  • 0

The code below is part of an autocomplete input created using JQuery UI.
But my question here is related to the JQuery-AJAX part only.

change: function(event, ui){
$.ajax({
type: "POST",
url: "includes/c_t_v_choices.php",
data: { filter: ui.item.value },
//dataType: "JSON",
}).done(function( msg ) {
    c_t_v_choices = msg;
    alert( "Data Saved: " + c_t_v_choices );
    $("#c_t_v").autocomplete("option", "source", c_t_v_choices);
});

The last line in the c_t_v.php file is:

echo json_encode($return_arr);

The way the code is currently, I see valid data in the alert, sent by the php file. An example is shown below:

Data Saved: [{"label", "value"}, {"label", "value"}...]

However, when I enable the line:

dataType: "JSON",

I see something like:

Data Saved: [object: Object], [object: Object]

Why this weird behavior?

On a side note, any idea why $(“#c_t_v”).autocomplete is accepting the source i am providing in the code below (which is part of the code above):

$("#c_t_v").autocomplete("option", "source", c_t_v_choices);
  • 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-12T07:19:02+00:00Added an answer on June 12, 2026 at 7:19 am
    Data Saved: [{"label", "value"}, {"label", "value"}...]
    

    Do a log on this data in this instance like this console.log(typeof your_data_var) — is it a string?

    When you specify JSON jQuery converts the returned json STRING into an object array so that you can easily access the json hierarchy using the dot notation, e.g. Parent.child.something.

    It is the normal way jQuery handles JSON responses as it is more elegant and faster to lookup than using an array 🙂

    PS In case you aren’t I recommend you use console.log, and console.dir can be handy for arrays/objects and inspect with Firebug to get a better understanding of the object and what it contains.

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

Sidebar

Related Questions

20120315021529.000[-8:PST] to get the first part I was able by using below C# code.
I am using a three part code below: First part of the code: Basically
The part I don't understand in the code below is function(serialized). I know change
I am using the jQuery autocomplete plugin and have wired up an input field
How can I change the code below so each part is added together in
The code below is part of an rss feed parser using WordPress's simplepie fetch_feed()...
I have a visual web-part for sharepoint with code below, but code of click-handler
I have part of the code below: while($array = $result->fetch_assoc() ){ $second_query = INSERT
In the code below, I think I messed up this part: if ( (1
Below, I inserted a code written by Ray Konopka (part of the Coderage presentation).

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.