![]() |
[SOLVED]Help with filling JSON object/array? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: [SOLVED]Help with filling JSON object/array? (/showthread.php?tid=26715) |
[SOLVED]Help with filling JSON object/array? - El Forum - 01-21-2010 [eluser]zimco[/eluser] Complete newbie with javascript/JSON, so forgive the uneducated. I am not even sure what i am working with an array or an object, but here's what i am trying to do: Passing the following variable to a JSON script in my CodeIgniter app: Code: var result = {"pageData":[{"page":{"@attributes":{"leafNum":"0"},"handSide":"RIGHT","origWidth":"500","origHeight":"1155"}},{"page":{"@attributes":{"leafNum":"1"},"handSide":"LEFT","origWidth":"650","origHeight":"1155"}},{"page":{"@attributes":{"leafNum":"2"},"handSide":"RIGHT","origWidth":"900","origHeight":"1155"}},{"page":{"@attributes":{"leafNum":"3"},"handSide":"LEFT","origWidth":"950","origHeight":"1155"}}]} The variable and values get to the script, but then when i try to get, gb.pageW, to contain the values [893,500,650,900,890] from the above variable with my code below, it does not work. Again, please forgive my bad coding if i am going about this all the wrong way. How are you supposed to do what i am attempting to do? (Note: changing "doc.write" to "doc.wryte" was intentional so it shows up in the forum post): Code: gb.pageW = [ [SOLVED]Help with filling JSON object/array? - El Forum - 01-21-2010 [eluser]Krzemo[/eluser] What about json_decode() php function? [SOLVED]Help with filling JSON object/array? - El Forum - 01-21-2010 [eluser]zimco[/eluser] Seems i was making it harder than it was: Code: var wArr = new Array(); |