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

  • Home
  • SEARCH
  • 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 8805337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:50:28+00:00 2026-06-14T01:50:28+00:00

On an ajax success function, I put some items into a dropdown using vktemplate

  • 0

On an ajax success function, I put some items into a dropdown using vktemplate. However, I’d like to attach some data to them so that when a user selects the name of an address, I can quickly pull out the whole address from the jquery data object.

This

success: function (returnedData) {

    $('.vendor_address_select').vkTemplate('templates/vendor_addresses_by_sector_dropdown_template.tmpl?<?=time()?>', returnedData, function () {

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

            //dropdown option looks like this:
            //<option id="vendor_address_id_22">company1</option>
            $('#vendor_address_id_' + id).data('address', {
                'vendorName': val.vendor_name,
                'address1': val.address1,
                'address2': val.address2,
                'city': val.city,
                'state': val.state,
                'zip': val.zip
            });

        });

    });
}

is giving me this error
Uncaught TypeError: Cannot call method ‘split’ of undefined

when i try to access the data like this:

$(document).ready(function () {
    $('.vendor_address_select').change(function () {

        var selectedAddress = $('option:selected', this);
        console.log(selectedAddress.data());

    });
});

How am I misusing jquery’s data()?

template file:

<% for ( var i = 0 in o ) { %>
<option id="vendor_address_id_<%=o[i].id%>">
<%=o[i].vendor_name%></option>
<% } %>
  • 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-14T01:50:29+00:00Added an answer on June 14, 2026 at 1:50 am

    You have to specify the key ‘address’ when using .data() like so

    $(document).ready(function () {
        $('.vendor_address_select').change(function () {
    
            var selectedAddress = $('option:selected', this);
            console.log(selectedAddress.data('address'));
    
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an jquery ajax success function which uses a template to put json
Here is the code I'm currently using: $.ajax({ success: function(){ $('.post_container').append('test <br />'); }
function checkSession(){ $.ajax({url: session.php, success: function(data){ if( data == 1){ var postFilen = 'msg.php';
jQuery code: function ajaxsubmit(){ $.ajax({ url: /update, type: POST, dataType: html }).success(function(data) { $('#result').html(data);
I've put together some jQuery AJAX code using some tutorials I found on the
Having issues referencing $(this) from within a the nested ajax 'success' function... I know
It seems that i cannot access $(this) inside jquery ajax success function. please see
Let's say on ajax success the function: xmlParser(xml) is called and the XML response
I'm trying to return the ajax success array from one function to another. For
I have a jquery json ajax call and inside my success function I have

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.