Currently when I want to get data from my database through ajax I use an external php file which just grabs the data from the database with mysqli and echoes the results and sends the data to ajax.
I now want to change that into a more effective solution. I thought I would first change it so that the php file outputs json data for future projects and easier data managament. But I don't want everyone else to be able to access this data directly other than through my website. And since you can see the ajax connection by inspecting the website it's really easy to find out.
I don't want it to become a place where everyone can just access the raw json data and build their own applications/websites from.
What other solutions are there? Only my web server should be able to access it.