how to send nested data to php? json

S

sskk

I am trying to send nested data.
I thought i can only send as json so i tried to make json text like the
following.

the structure has 3 levels ( continents, countries, state )
"{ 'continents' : [{ 'continent': '1', 'countries': [{ 'country': '3'}]}]}"
just to make the json text takes forever.

Is there another solution to this?

for (var continent in arrRepRegions) {
if( $l == 0 ){
jsonRepRegions += "{ 'continent': " + continent;
$l++;
}else
jsonRepRegions += ",{ 'continent': " + continent;

for( var country in arrRepRegions[continent] ){
if( $j == 0 ){
jsonRepRegions += ",'countries': [";
$j++;
jsonRepRegions += "{ 'country': " + country;
}else{
jsonRepRegions += ",{ 'country': " + country;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top