Even though I know PHP is a server-side script and JavaScript is client-side, I encountered an issue.
I struggled to bypass browser security when making an AJAX request to another domain. Feeling lost, I decided to turn to PHP for help.
The challenge I faced was that I could only use JS and CSS to manipulate my tracking system!
My goal was to incorporate a newsfeed.csv, so I crafted this PHP code to retrieve the CSV file, convert it, and store it in the variable $json.
<?php
$file="http://www.jonar.com/portal/partner/js/newsroomcustomer.csv";
$csv= file_get_contents($file);
$checkit = utf8_encode($csv);
$array = array_map("str_getcsv", explode("\n", $checkit));
$json = json_encode($array);
?>
I am wondering if there's a way to perform an AJAX GET request to receive the output variables—basically the JSON format of my CSV.
This method would allow my PHP script on the webserver to access links from any domain.
Thank you all for your help :)