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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:51:53+00:00 2026-06-11T20:51:53+00:00

How can I put this JSON Object in the function or object below? //

  • 0

How can I put this JSON Object in the function or object below?

// this function generates an JSON Object dynamically       
$(".n_ListTitle").each(function(i, v) {
    var node = $(this);
    var nodeParent = node.parent();
    var nodeText = node.text();
    var nodePrice = node.siblings('.n_ListPrice');

    var prodPrice = $(nodePrice).text();
    var prodId = nodeParent.attr('id').replace('ric', '');
    var prodTitle = nodeText;

    var json = {
        id : prodId,
        price : prodPrice,
        currency : "CHF",
        mame : prodTitle
    };
    return json;
});

TDConf.Config = {
    products : [
        // here should be inserted the JSON Object
        {id: "[product-id1]", price:"[price1]", currency:"[currency1]", name:"[product-name1]"},
        {id: "[product-id2]", price:"[price2]", currency:"[currency2]", name:"[product-name2]"},
        ...

    })],
    containerTagId :"..."
};

If it is not understandable please ask 🙂
Thanks in advance for helping me to figure out!

  • 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-11T20:51:54+00:00Added an answer on June 11, 2026 at 8:51 pm

    Your function does not do what you think it does ( the return statement inside .each can only break a loop ). Try this:

    TDConf.Config = {
        products : [],
        // some other stuff
    }
    $(".n_ListTitle").each(function(i, v) {
        // some other code
        var json = {
            id : prodId,
            price : prodPrice,
            currency : "CHF",
            name : prodTitle
        };
        TDConf.Config.products.push( json );
    });
    

    You should learn more about JavaScript, scoping and obviously JSON, because you don’t seem to understand that what you are dealing with is actualy not JSON, it’s a JavaScript object ( slight difference but still a difference ).

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

Sidebar

Related Questions

I can put python doctests in the bodies of each function, which I sometimes
For example I have this ajax function but I can call only one json
My JSON object is constructed like this: var Source = { Object: [ //Array
Can somebody help me with this: this is my code: //js var TestPlugin={ test:function(name,successCallback,failureCallback){
If you have a string of 1,2,3,1,5,7 you can put this in an array
How can i put this string in to a cell using java apache poi?
Maybe a very simple question. How can I put in this code <Query> <Where>
I'm developing this application where you can put text and drawings in a page.
I'm trying to build a screen like this: How can I put my span
I can't seem to get back on track with this one. I simply put

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.