1. Scene
Ajax requests the php script to return a 404 status code, but the php script can output data, causing the ajax callback function to be unable to continue execution.
Troubleshooting process:
1. I suspect that there is a problem with the framework I wrote. I request the ajax request script path in the browser window and the page can be opened normally.
2. Write a php script, directly output a string in json format, use ajax to request, and still return status code 404.
3. Write an html page and use ajax to request it. The return status code is 405.
4. Check the nginx configuration parameters and find that there is a problem with the fastcgi configuration.
Solution:
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; }
changed to
location ~ \.php$ { root /www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /www/$fastcgi_script_name; include fastcgi_params; }
root runs the root directory for the website.
/scripts Change to the website root directory.