I have a php file where I retrieved data from the server. I want to parse the data into my pure Javascript file in order to store it in an array.
This is my php code:
$dir = "images";
$folders = array_diff(scandir($dir), array('..', '.'));
$folders = array_values($folders);
print_r($folders);
$encodedArray = json_encode($folders);
print_r($encodedArray);
I want to send over the encodedArray to my pure Javascript file as I want to put them into an array to use. Is it possible to send it to a pure JS file?
fetch/ Axios /XMLHttpRequest) to load the PHP script that outputs JSON.