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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:23:21+00:00 2026-05-23T11:23:21+00:00

This piece of code does not execute the code block inside the callback function

  • 0

This piece of code does not execute the code block inside the callback function for result():

var cityURL = '/myURL/path';
    $('#city').autocomplete(cityURL, {
        cachelength:0
    }).result(function(event, data){
       if(data){           
            $('#city_id').val(data[1]);
            $('#state_id').val(data[3]);
            $('#state').val(data[2]);
       }
    });

the value of input#city_id and input#state_id does not change, but the value for #state does change. Both are hidden input right next to their field:

<input type="text" id="city" name="city"/>
<input type="hidden" id="city_id" name="city_id" />

<input type="text" id="state" name="state"/>
<input type="hidden" id="state_id" name="state_id" />

however, if I put an alert, the values change:

$('#city').autocomplete(cityURL, {
    cachelength:0
}).result(function(event, data){
   if(data){       
        alert(data[1]);
        $('input#city_id').attr('value',data[1]);
        $('input#state_id').val(data[3]);
        $('input#state').val(data[2]);
   }
});

why is this?

EDIT: Scratch that, the values do not change even with an alert:

  • 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-23T11:23:22+00:00Added an answer on May 23, 2026 at 11:23 am

    As I suspected in my comment, it’s just Firebug that’s not updating properly. You shouldn’t trust the input value attributes it shows as they’re often out of date.

    A reliable way to check input values is to just use JS and enter something like $("#foo").val(); in the console.

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

Sidebar

Related Questions

I have this piece of code that does not work: public CartaoCidadao() { InitializeComponent();
This piece of code used to work in MVC 1 but it does not
This is my piece of code which does not work. if ( $(div#verticalScrollbar).css(top) >=
I'm not entirely sure why this isn't working. But this piece of code does
Is this piece of code where I lock a part of the function correct?
How I can execute a JavaScript function/piece of code in a specific context which
Why does this VBA code not work?: Sub AllToGeorgia12() Selection.Font.Size = 12 Selection.WholeStory Selection.Font.Name
I am testing this piece of code but when I run it, it does
I want a piece of code which does not involve loops but automatically generates
I have this piece of code: $('#contentSites').fadeOut(200, function() { // Animation complete $.get(my_account_content.php?q= +

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.