Eunico Cornelius Posted April 4, 2018 Posted April 4, 2018 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)
psy Posted April 4, 2018 Posted April 4, 2018 @Eunico Cornelius Just a thought... on your template have you checked Disable automatic prepend of file: _init.php and/or Disable automatic prepend of file: _main.php? 1
Eunico Cornelius Posted April 4, 2018 Author Posted April 4, 2018 The solution: Just need to disable the appending main page from the template. Thanks for your help @psy 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now