Ajax request PHP Error 404 But the script will be able to output data problem solving method _php Tutorial

Source: Internet
Author: User
Tags php error

Ajax request PHP Error 404 But the script will be able to output the problem of data resolution method


1. Scene

Ajax requests that the PHP script return a 404 status Code, but the PHP script can output the data, causing the Ajax callback function to fail to execute.

Troubleshooting process:

1, the suspicion is that the framework of their own problems, in the browser window request Ajax Request script path, the page can open normally.

2, write a PHP script, directly output a JSON-formatted string, with the AJAX request, still return the status code of 404.

3. Write an HTML page with an AJAX request and return a status code of 405.

4, troubleshooting Nginx configuration parameters, found that there are problems with fastcgi configuration.

Workaround:

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

What to modify:

Root runs the root directory for the Web site.

/scripts changes to the Web site root directory.

http://www.bkjia.com/PHPjc/990599.html www.bkjia.com true http://www.bkjia.com/PHPjc/990599.html techarticle Ajax request PHP error 404 But the script can normally output data problem Resolution 1, the scene Ajax request PHP script returned 404 status code, but the PHP script can output data, resulting in the return of Ajax ...

  • Related Article

    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.