Google has failed me. Does anyone have a good reference on getting vanilla javascript or jquery to talk to a PHP site? For background: All on the same domain, same server but on multiple subdomains Subdomains A, B, C serve public content Subdomain D holds the admin system Subdomain Z holds files including javascript, css, images used by all other subdomains Subdomain A wants to get some autocomplete json from Subdomain D Instead, I'm just going to copy over the code but it seems unnecessary. If you have any ideas I'd love to convert it back and do it properly.
What is the problem you are running in to? It *seems* to me based on the info provided that you are creating some sort of frontend that retrieves info from a PHP script that acts as an API serving data in JSON format and you are running in to issues with your code that is being denied by the server? If this is the case sounds like the PHP script has code restricting access to it's API from approved domains. What is the issue you are running in to?
Chrome threw a corb error and returned nothing. The server returns 200, and when called directly or via postman the output is correct. All the cors stuff is in there. I've written all the code but because the code calls another API I was wanting to have a single point of contact.
Okay it's the normal CORS issue. If you use Apache Webserver, you can add this: Header Set Access-Control-Allow-Origin "*" to your Sub Domain D vhost file. You can also add it to your .htaccess file in the root of Subdomain D. Alternatively, you can do it from PHP by adding this: header("Access-Control-Allow-Origin: *"); Lastly, if Subdomain A is accessed only by you and you use Google Chrome, you can simply just download any "Allow-Control-Allow-Origin" Extension from Chrome store. They will disable the security feature on Chrome. But this will only make it work on your computer.
Nah, sorted out the cors issues. This was another layer, and I can't control the browser that people use.