0

I have dynamic price change table, and I want to change my price list from data json dynamically,

I want to get data.Items.Onelow and data.Items.Onehigh values from json data with dynamic variable; But I have problem; My codes under below.

$.ajax({
            type: 'GET',
            url: "data.json",
            dataType: "json",
            contentType: "application/json",
            cache: false,
            success: function(data) {

            var a = ["One", "Two"];
            a.forEach(function(entry) {


            var entry_data_low = data.Items.entry+low; // HERE Problem
            var entry_data_high = data.Items.entry+high; // HERE Problem




            });




        }
    },2000);

      });
    });
3
  • "A problem" being, low and high are undefined, I guess? Commented Apr 8, 2020 at 14:54
  • jeremy Thile yes Commented Apr 8, 2020 at 15:13
  • Well, define them, then :) Commented Apr 9, 2020 at 13:18

1 Answer 1

1

You should replace this line from

var entry_data_low = data.Items.entry+low; // HERE Problem
var entry_data_high = data.Items.entry+high; // HERE Problem

to

var entry_data_low = data.Items.entry + "low";
var entry_data_high = data.Items.entry + "high";

considering object property is as data.Items.Onelow and data.Items.Twolow.

Sign up to request clarification or add additional context in comments.

2 Comments

says undefinedlow undefined high
after using string notation it should not say so. Try this data.Items[entry+"low"]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.