Patrickkx Patrickkx - 9 months ago 41
JSON Question

PHP: Export a JSON file and catch it by JS

Got a php code:

$date = date("Y/m/d");
echo json_encode($date);

It exports a json file. But then, I wanna catch it by JS:


But my problem is - how can I know where the JSON file was saved (if it even was saved)?

Does the
echo json_encode($date)
exports a json file to somewhere? Or echo has nothing to do with that?

Thanks for any further help.

Edit: Anybody can help me?

Answer Source

Your are doing correctly in php side but in jquery side i dont know if $.get().done() works or not

i have used it by this way and its working fine

$.getJSON( "url/yoururl", function( data ) { 


You can also use


console.log(data) will return date which you have exported from php