Php file not found

Php file not found


I tried to call php script I created inside the project using ajax but returns a 404 not found error.


var xhr = new XMLHttpRequest();'GET', './assets/script/api-rate.php');

xhr.onreadystatechange = function() {
    if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status <= 207)) {


this is the path of my php file in the project


Cocos does not support php. Why do you use it? Better to use js and your game will be cross-platform


I’m currently implementing it on Cocos Creator.


So, your target platform is only web?

Sorry for off-topic, just interesting


Yes. I was planning to GET request from php cause if I done it directly from javascript, it doesn’t let me access to a domain because of CORS policy.


It is now okay. The php file should be inside the build folder instead on the project folder.

#7‘GET’, ‘…/build/api-rate.php’); ???
or‘GET’, ‘…/build/web-desktop/api-rate.php’); ???