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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:35:46+00:00 2026-06-14T10:35:46+00:00

I am trying to attach some data to options in a select menu of

  • 0

I am trying to attach some data to options in a select menu of a particular class using jquery data() that are coming from a jquery ajax() call. But I am getting the error that it is not getting attached when I try to call it. Or, more accurately that it is not getting applied at all, as the console.log($(this).data('address'.vendorName)); in the antipenultimate line of code below gives me the error Uncaught TypeError: Cannot read property 'vendorName' of undefined

The inner $.each() loop is a last-stab attempt because I thought that perhaps just using
$('.vendor_address_id_' + id).data.... wasn’t being applied to all the elements with that class. But I don’t really think it should be necessary. What am I doing wrong?

$.each(returnedData, function (key, val) {
    var id = val.id;

    //attach address information to each select option for display in .vendor_full_address_table
    $('.vendor_address_id_' + id).each(function (k, v) {

        $(this).data('address', {
            'vendorName': val.vendor_name,
            'address1': val.address1,
            'address2': val.address2,
            'city': val.city,
            'state': val.state,
            'zip': val.zip
        });
        //gives error: Uncaught TypeError: Cannot read property 'vendorName' of undefined 
        console.log($(this).data('address').vendorName);
    });
});



//console.log(returnedData);
Object
    address_0: Object
        address1: "street address1"
        address2: ""
        city: "Kalamazoo"
        id: "15"
        state: "MI"
        vendor_name: "companyA"
        zip: "123456"
    address_1: Object
        etc...
        etc...
        etc...
    address_2: Object
        etc...
        etc...
        etc...
  • 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-14T10:35:50+00:00Added an answer on June 14, 2026 at 10:35 am

    Instead of

    val.vendor_name
    

    Use

    returnedData.vendor_name
    

    Here val is the Value of the particular returnedData[key] value in the iteration.

    And you are trying to access a property from a primitive type which is the val here .

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

Sidebar

Related Questions

I have this javascript that pulls some data via an ajax request the method
I am trying to attach an image that is picked from the image gallery
I'm trying to develop a mobile application for some site, that using HTML form
I'm trying to attach my database on a server that is running SQL2005 and
I am trying to attach my mdf files to SQL server (using windows XP)
ok, I'm trying to figure out how to put some data into an inline
Possible Duplicate: What does jQuery.fn mean? I have some script on a page trying
I'm trying to add some custom data within a tag to reference later in
Using the data() function I add two values to some divs ( $oRow points
I am trying to perform a multivariate test for normality on some density data

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.