simple thing.
$.getJSON is used and the result from the .php file being called is caught as response in the jquery callback function. The json encoded php array is an associative array.
$.getJSON("file.php",function(response){ // print the associative response array in var_dump or print_r fasion }); file.php contains:
<?php $my_array=array(); //$my_array['random_index1']="random_value1"; //$my_array['random_index2']="random_value2"; //$my_array['random_index3']="random_value3"; // and so on echo json_encode($my_array); ?> $my_array has random keys and values.
How can I print the whole 'response' array just like the print_r fashion in php?
EDIT1: I want to print it on the webpage or in an alert box. Not that i just want to watch the values in the javascript console(chrome, FF or whatever).
EDIT2: if I write the body of $.getJSON as follows: why won't it work:
for(var i in response){ console.log("i="+i+" content="+response[i]); }