I have tried too many codes to achieve the following:
$(document).ready(function(){
var json_data = $.getJSON('url_to_json_encoded_array.php',function(j){
return j;
});
});
if(json_data.length > 0){
//fetch data from the json_data json ecoded array here
}
But after running the code I always get json_data is with no data, while in developer tab -> network-> i can see that the data loaded in proper mode....
php code which returning the json encoded array is as following:
<?php
echo(json_encode(array("name"=>$name,"email"=>$email)));
?>
What is wrong in my code?