echo javascript json array
i have a script that's retrieving a json string through ajax.
if i alert(data), i get: {"account_id":805267,"customer_id":882315,"account_name":"","account_number":"6011xxxxxxxxxxx0000"," enabled":false,"type":"2","bank_name":"","cc_name":"","expiration":"1215","is_savings":false,"date_a dded":"20120210","date_modified":"20120210"} in a popup window... but if i alert(data.account_number), i get "undefined" in a popup window. what am i doing wrong? |
BAH!!! (need to be reviewing my javascript books and notes everyday)
alert( $.parseJSON(data).account_number ); does it. |
You don't need to use $.parseJSON() in AJAX call. Instead you should use $.getJSON() or set dataType to 'json' for $.ajax(). This way jQuery will parse JSON data for you, and you'll be able to use it right away.
|
All times are GMT -5. The time now is 01:32 AM. |