What is wrong with my code below? I am passing to this function a JSON string but the assignment ends up blank. I can see the string in FireBug in the function parameter so I know it arrives at the function, but it does not make it past the assignment (as in the assignment is "undefined"). I want to pull from the string the wty_upgrade array. I am using some of the code I received help with in this question. Thanks
JSON string (as I see it in FireBug:
{"wty_upgrade":[
{"wty":"Upgrade from 3 to 5 years", "mth":24, "pig":3000},
{"wty":"Upgrade from 3 to 10 years", "mth":84, "pig":8000}
]}
Function Call:
LoadWtyUpgPlans('3', JSON)
function LoadWtyUpgPlans(StdWty, UpgWty) {
var WtyRow = '';
var WtyUpgrades = UpgWty.wty_upgrade; <--- here the assignment is blank/undefined
STUFF HERE...
};
JSON = "at the beginning and the"at the end (e.g., as in the question you linked).". I even checked the validity of JSON syntax herehttp://jsonlint.com/and it is OK (without the outside").alert(JSON)it looks exactly as above. If Ialert(JSON.wty_upgrade)it shows upundefined