Ajax requests php error 404, but the script can normally output data to solve the problem _ PHP Tutorial

Source: Internet
Author: User
Tags php error
Ajax requests php to report error 404, but the script can properly output data. Ajax requests php to report error 404, but the script can normally output data. Solution 1. the scenario ajax requests the php script to return a 404 status code, but the php script can output data, A solution that causes ajax to return ajax requests to php to report error 404 but the script can output data normally

1. scenario

Ajax requests the php script to return a 404 status code, but the php script can output data, causing the ajax callback function to fail to be executed.

Troubleshooting process:

1. if you suspect that the framework you have written is faulty, request the ajax request script path in the browser window, and the page can be opened normally.

2. write a php script and directly output a json string. for ajax requests, the return status code is 404.

3. write an html page with an ajax request. the returned status code is 405.

4. check nginx configuration parameters and find that fastcgi configuration is faulty.

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;        }

Change

 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;        }

Modification content:

Root is the root directory of the website.

/Scripts to the root directory of the website.

Http://www.bkjia.com/PHPjc/990599.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/990599.htmlTechArticleajax request php error 404 but the script can normally output data problem solution 1, the scenario ajax request php script returns 404 status code, but the php script can output data, cause ajax back...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.