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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:53:55+00:00 2026-06-16T23:53:55+00:00

Based on this SO answer , I’m doing this: $(document).ready(function () { $(‘#stateid’).change(function ()

  • 0

Based on this SO answer, I’m doing this:

$(document).ready(function () {
    $('#stateid').change(function () {
        $.ajax({
            url: "/admin/state_teamlist.php",
            data: {
                stateid: $("#stateid").val()
            },
            dataType: "json",
            success: function (json) {
                $('#teamid').empty().each(json, function (value, key) {
                    $('#teamid').append($("<option></option>")
                        .attr("value", value).text(key));
                });
            }
        });
    });
});

Data returned is valid JSON (from PHP’s json_encode):

{"16734":"Anchorage Christian","12241":"Barrow","1060":"Bartlett","1064":"Chugiak","5802":"Colony","1061":"Dimond","1058":"Eagle River","1063":"East","3943":"Eielson","7104":"Homer","11597":"Houston","5568":"Juneau-Douglas","10229":"Kenai Central","14260":"Ketchikan","9444":"Kodiak","8443":"Lathrop","12152":"Monroe Catholic","7554":"Nikiski","4082":"North Pole","1065":"Palmer","1057":"Service","14370":"Seward","12271":"Sitka","11780":"Skyview","3308":"Soldotna","844":"South","9919":"Thunder Mountain","13803":"Valdez","9766":"Wasilla","1059":"West","1062":"West Valley"}

But I’m getting this error:

Uncaught TypeError: Object # has no method ‘apply’

The error line in jquery.JS is:

if ( callback.apply( obj[ i++ ], args ) === false ) {

The full part around this is:

// args is for internal usage only
    each: function( obj, callback, args ) {
        var name,
            i = 0,
            length = obj.length,
            isObj = length === undefined || jQuery.isFunction( obj );

        if ( args ) {
            if ( isObj ) {
                for ( name in obj ) {
                    if ( callback.apply( obj[ name ], args ) === false ) {
                        break;
                    }
                }
            } else {
                for ( ; i < length; ) {
                    if ( callback.apply( obj[ i++ ], args ) === false ) {
Uncaught TypeError: Object #<Object> has no method 'apply'
                        break;
                    }
                }
            }

        // A special, fast, case for the most common use of each
        }

The teamid select list empties correct, but isn’t repopulated with the JSON data. I can post the HTML if needed, but I don’t think that’s a problem.

I’ve been through every SO answer on the topic but none of the solutions have fit my problem. Why am I getting this error?

I’ve tried jquery.min.js, different versions of jquery, changin the $('teamid') to the $el like in the references SO answer, and using .post and .get instead of .ajax and nothing seems to solve it. Please help.

  • 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-16T23:53:56+00:00Added an answer on June 16, 2026 at 11:53 pm

    Why are you chaining empty() and $.each ? It doesn’t make sense to chain them in this particular example.

    $('#teamid').empty().each(json, function (value, key) {
         $('#teamid').append($("<option></option>").attr("value", value).text(key));
     });
    

    Do one at a time.

      $('#teamid').empty(); 
      $.each(json, function (value, key) {
          $('#teamid').append($("<option></option>").attr("value", value).text(key));
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Based on this answer Get the subdomain from a URL , I am trying
This question is based on this answer . I'm looking for a function similar
Based on this answer - how to change classes on click can somebody explain
This is a further question based on this answer: How can I implement a
Based on the answer for this question What's the difference between CompositionBatch and catalogs?
Based the accepted answer to this question I've setup a NetBeans/tomcat environment. In testing
This question is based on my previous question which I got a working answer
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from
Based on this answer the model for the TFS 11 burndown chart is for
Based on this answer Regular Expressions: Is there an AND operator? I tried the

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.