传递任何数据时,仅Ajax Post错误500

时间:2019-10-29 10:35:27

标签: ajax

仅当我通过任何

时,才会发生错误

数据:,

到我的ajax。我试图将其放在URL中,在数组中,更改名称,...没有改变结果。如果删除数据,我将得到正确的200状态响应。

如果我直接访问该页面,没问题,仍然是200。

我的ajax函数:

$( "#deleteMool" ).click(function() {

                $.ajax({
                    url : '/Trunk/SofastBS/mool-delete',
                    type : 'POST',
                    data : 'mool=' + '4'  ,
                    dataType : 'html' ,
                    success : function(code_html, statut){

                        if (code_html == 'OK') {

                            location.reload();

                        }   
                    },
                });

        });

我的PHP页面:

<?php

$ID = $_POST['mool'];

// Check if user is logged in 
if ( is_user_logged_in() ){

    /*.................. Empty request block ...............*/
    if ($ID != ''){

        $mool_id = delete_mool( $ID ) ;

        //On success
        if ( $mool_id == true ) {
            echo 'OK';
        }
        else{

            echo 'Une erreur est survenue.';

        }
    }
    else {

        header('Location: '.site_url());
        echo 'ID EMPTY';

    }
}
else {

    header('Location: '.site_url());
    echo 'NOT LOGGED IN';

}   

我的头:

响应头:

HTTP/1.0 500 Internal Server Error
Date: Tue, 29 Oct 2019 10:19:37 GMT
Server: Apache
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Link: <http://192.168.1.95/Trunk/SofastBS/wp-json/>; rel="https://api.w.org/"
Link: <http://192.168.1.95/Trunk/SofastBS/?p=400>; rel=shortlink
Content-Length: 1
Connection: close
Content-Type: text/html; charset=UTF-8

请求标头:

POST /Trunk/SofastBS/mool-delete HTTP/1.1
Host: 192.168.1.95
Connection: keep-alive
Content-Length: 6
Accept: text/html, */*; q=0.01
Origin: http://192.168.1.95
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://192.168.1.95/Trunk/SofastBS/mool/
Accept-Encoding: gzip, deflate
Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7
Cookie: wordpress_test_cookie=WP+Cookie+check; wordpress_logged_in_censored_by_me; wp-settings-1=mfold%3Do; wp-settings-time-1=1572342088; PHPSESSID=65hhsmd6290lrei04se2tc8c93

为了进行比较,我在另一个站点的另一个Web部件中使用了相同的代码,并且可以完美地工作:

以下是工作位的标头:

响应头:

HTTP/1.1 200 OK
Date: Tue, 29 Oct 2019 10:29:38 GMT
Server: Apache
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Link: <http://192.168.1.95/trunk/nagacount/wp-json/>; rel="https://api.w.org/"
Link: <http://192.168.1.95/trunk/nagacount/?p=79>; rel=shortlink
Content-Length: 2
Keep-Alive: timeout=5, max=95
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

请求标头:

POST /trunk/nagacount/mool-delete HTTP/1.1
Host: 192.168.1.95
Connection: keep-alive
Content-Length: 5
Accept: text/html, */*; q=0.01
Origin: http://192.168.1.95
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://192.168.1.95/trunk/nagacount/mool/
Accept-Encoding: gzip, deflate
Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7
Cookie: wordpress_test_cookie=WP+Cookie+check; wordpress_logged_in_censored_by_me; PHPSESSID=65hhsmd6290lrei04se2tc8c93

我对此停留了一会儿,我确定我想念一些东西,但是我找不到。有什么提示吗?

0 个答案:

没有答案