Hey guys, I am trying to pass a JSON object from my javascript file using ajax, to my php file so i can dynamically send an email.
However, on my console I am receiving an error message:
XML Parsing Error: no root element found
Location: file:///C:/Users/tekke/Documents/My%20Websites/fulledm/sendEmail.php
Line Number 6, Column 3:
Mind you, I am doing this on my local computer without a local server running, could this be the issue?
Well for starters, you’re telling PHP to var_dump the decoded JSON, which has an output that is NOT itself JSON, so you’ve got a content type mismatch between the header and the code.
But yes, the problem is because you’re referencing a file://, rather than localhost via a server.
So even though it might be possible to run PHP exclusively from the command line, it would be unusual. And if you are going to use PHP to output to a browser (i.e. web pages) you will need a server other than the built in one.