Jump to content

Plain JSON PHP file in a template with ProCache


Eunico Cornelius
 Share

Recommended Posts

Hi, I am trying to create a PHP page in my website that is hidden and produce a plain JSON format. However, when I implement json_encode on my string, the result is not only a plain JSON but also a <!DOCTYPE HTML>.... I have created a new page and a new template that has it's cache disabled, but it still doesn't work.

this is what my code looks like 

<?PHP
$useMain=false;
$data = "[{'title':'AAAAA','url':'https://google.com'}]";
header('Content-Type: application/json');
echo json_encode($data);
?>

This is what I currently get

"[{'title':'AAAAA','url':'https:\/\/google.com'}]"<!DOCTYPE html><html>....</html>

This is what I am trying to achieve

"[{'title':'AAAAA','url':'https:\/\/google.com'}]"

What am I missing here? I am also using ProCache.(dont know if it has any influence since I created and disable cache in a new template)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...