JSON file permissions

I’m using a number of JSON files with AJAX so I set the permissions to 640 to stop the world from being able to view them but by doing so AJAX then doesn’t work…

What gives? Is there a work around for this?

Ajax just makes requests like a normal browser request that you’d type into the address bar. So to bypass this problem you need to access them via a server-side script. Since the script runs on the server, it will be able to access them.

I wanted to check email addresses and usernames to make sure that there are no duplicates during JavaScript validation…

If I was to do this with a server-side script through jQuery AJAX then the only response would be if the script has finished running or not. It’s not possible to pass back conditionals declaring whether a duplicate has been found in the database… or maybe it is?

Yes it is - that’s the point of AJAX. It’s a request, so the server can send back a response. Often the response is sent as JSON, which I assume is what you want to do. This JSON can be static (e.g. in a txt file) or generated on the fly by a server-side script.