What do you get when you visit the page? Both of your codes are working fine on my end.
![Tongue](https://bitcointalk.org/Smileys/default/tongue.gif)
It returns
9753.4870488971, which matches what the API
endpoint returns (with the last digit being rounded).
Yup, both of his codes are working fine. I checked it as well.
Something similar happened to me once, there was nothing wrong with code and still it wasn't working. Turned out that my server's IP address was being blocked by Cloudflare. Maybe something similar is happening to OP.
Try making a simple curl request to the api, and see what response you get.