I am trying to figure out how to access data in a substantially multidimensional JSON array.
My jQuery AJAX request is as follows:
$("#login-form").submit(function(e) { e.preventDefault(); $.ajax({ type: 'POST', url: '/ajax/login', data: 'email='+$("#email").val()+'&password='+$("#password").val(), success: function(data){
This is what I am returning. User account information, as well as a list of products that they have against their account.
{ "logged_in":true, "firstname":"Joe", "surname":"Bloggs", "Full_name":"Joe Bloggs", "email":" email@website.com ", "phone":"+123456789", "website":"", "age":"26-35", "street":"1 Street Ave", "city":"Townland", "state":"NA", "postcode":"1234", "country":"Australia", "products":2, "0":{ "product_no":"1087", "customer":"2", "bought_from":"1", "date_of_purchase":"2011-04-08", "method":"instore", "invoice":"0", "current":"1" }, "1":{ "product_no":"24", "customer":"2", "bought_from":"1", "date_of_purchase":"2011-04-08", "method":"instore", "invoice":"0", "current":"1" } }
As you can see, I am warning about the first name, and this is normal. I can access everything in the first dimension using data.key, but I'm not sure how then I need to index the next dimension. Obviously, I would like to somehow display each of the products.
Suggestions would be welcome.