First use 'json_decode' to convert array to JSON response
$test = [ "connections" => [ [ "title" => "Connection 1", "date" => "01-26-2010", "id" => "1" ] ] ];
echo json_encode( $test );
and then process the JSON response in the front-end side.
$.get( 'http://cnbusiness.nextdayhost.com/ajax/get_business_connections', function(e){
console.log( e.connections );
});
but unfortunately it returns 'undefined'
A view of the response using a JSON editor
I can do this
$.get( 'http://cnbusiness.nextdayhost.com/ajax/get_business_connections', function(e){
$.each(JSON.parse(e),function(i,e){
$.each(e,function(i,e){
console.log(e.title);
});
});
});
which surely returns the data that I want but I prefer not to do a second loop.
any idea, help please?