netpumber Posted July 11, 2014 Share Posted July 11, 2014 Hello. Server returns this json {"status":1,"job_status":"READY","iterations":["Contig2","Contig75"],"accessions":["NP_001061702","NP_001068174"]} And i would like to print out in a textarea (using the above jQuery command) $('#info').val() something like this: Contig2 : NP_001061702 Contig75 : NP_001068174 Any idea on how to achieve this? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/289742-parse-a-json-with-arrays-inside-it/ Share on other sites More sharing options...
requinix Posted July 11, 2014 Share Posted July 11, 2014 When you did the AJAX stuff you had the option to specify the type of data to return. Tell jQuery to use JSON. Then you'll get an object in your callback function with .status and .job_status and such. Quote Link to comment https://forums.phpfreaks.com/topic/289742-parse-a-json-with-arrays-inside-it/#findComment-1484733 Share on other sites More sharing options...
netpumber Posted July 13, 2014 Author Share Posted July 13, 2014 Yeah i know that, but i don't know how to parse the Arrays inside that json object. To print out the status i can write this : $('#info').val(json.status) but how can i write down data from the arrays in the form i wrote before ? Quote Link to comment https://forums.phpfreaks.com/topic/289742-parse-a-json-with-arrays-inside-it/#findComment-1484908 Share on other sites More sharing options...
requinix Posted July 13, 2014 Share Posted July 13, 2014 You don't have to do any parsing. It's done for you. If you're looking to get the Contig2 value, that'd be .iterations[0]. Quote Link to comment https://forums.phpfreaks.com/topic/289742-parse-a-json-with-arrays-inside-it/#findComment-1484943 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.