I have a json string that when I put it into the eval function it only returns the last object in the string. Anyone possibly know why
views:
68answers:
1
A:
This is what happening I guess:
<script>
alert(eval("{firstname: 'Ramiz'; lastname: 'Uddin'}"));
</script>
This will prompt you the last value "Uddin". And a fix of the above script can be:
<script type="text/javascript">
alert(eval({"firstname": "Ramiz", "lastname": "Uddin"}));
</script>
So, my guess is you should look into your JSON script which might have problems.
Ramiz Uddin
2010-01-26 05:37:19
Thanks you were right, the problems was that I had multiple objects being returned from php so I had to separate each of those objects into separate strings and then the function worked perfectly
Daquan Hall
2010-01-26 21:14:51