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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:00:36+00:00 2026-06-04T21:00:36+00:00

Would anyone mind explaining to me why… $(document).ready(function() { var scu = [‘0291285’, ‘0409338’,

  • 0

Would anyone mind explaining to me why…

$(document).ready(function() {
    var scu = ['0291285', '0409338', '0521704', '0521990', '0523652', '0523657', '0523660', '0523704'];
    var inData = $('#output');
    var testdiv = $('#testdiv');
    function Item(scu, description, price, extended, type) {
        this.scu = scu;
        this.description = description;
        this.price = price;
        this.extended = extended;
        this.type = type;
        //this.saved = function() {};
    }
    var rows = [];
    function get() {
        inData.html('');    
        $.each(scu, function(index, val) {
            $.post('chBuild.php', {scu:val}, function(output) {
                $.each(output, function(i, obj) { 
                    var i = 0;
                    rows[i] = new Item(obj.scu, obj.description, obj.price, obj.extended, obj.type);
                    console.log(rows[i].price)
                                    //this logs every object but...                 

                    i =+ 1;
                });
            }, 'json');         
        });
        console.log(rows[0].price);

            //this says rows[0] is undefined?

    }
    inData.click(get);
});

I am trying to find the best way to create and store multiple objects.

  • 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-04T21:00:37+00:00Added an answer on June 4, 2026 at 9:00 pm
    $.post('chBuild.php', {scu:val}, function(output) {
                $.each(output, function(i, obj) { 
                    var i = 0;
                    rows[i] = new Item(obj.scu, obj.description, obj.price, obj.extended, obj.type);
                    console.log(rows[i].price)
                    i =+ 1;
                });
            }, 'json');         
    

    Here the call to $.post is asynchronous, is going to be filled just when the ajax call returns. Maybe you should make it synchronous

    $.ajax({'url': 'chBuild.php', 'async': false, ...);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would anyone now why this script is disabling my nav in webkit browsers $(document).ready(function
Apparently a colon is used in multiple ways in Java. Would anyone mind explaining
Would anyone mind explaining (or pointing me to a tutorial) how to setup an
Would anyone mind having a look at these bits of code and see if
I have been delving into C# recently, and I wonder if anyone would mind
C++ when used in networking is completely cryptic to me. Would anyone mind helping
Has anyone used Pydbgr with Emacs and if so would they mind sharing their
Would anyone be able to tell me how to pull the server name out
Would anyone offer tips, links, code snippets on how to browse to a file
Would anyone like to recommend free alternative to SharePoint Portal ? We want to

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.