Accessing database data with jQuery using a PHP proxy and avoiding the 404 error

I needed to pull database records into a page but couldn’t use PHP directly on that page (it was limited by the CMS used).
So what I did was to get the content I needed using a PHP file (‘get-posts.php’):

Above is the final code used for this file, but when I initially tried the integration I kept getting a 404 error message in JavaScript for the php file I was trying to access.
The solution was adding the header code which started the output with an “OK this page exists”.

The jQuery code I used to read the data:

Leave a Reply

Your email address will not be published. Required fields are marked *