$ .ajax从服务器获取数据,状态为200,但响应为空

时间:2017-01-18 02:28:13

标签: php json ajax encode

$ .ajax从服务器获取数据,状态为SELECT CASE WHEN description REGEXP '^A [^aeiou]' THEN CONCAT('An ', TRIM(LEADING 'A ' FROM description)) ELSE description END AS description FROM yourTable ,但响应为空。我使用相同的方法发送我的ajax请求,有些是正常的,但有一些请求

  

/客户/ API /显示/ R:571 NAV =推

?      

/客户/ API /显示/ R:571 NAV =推送安培;状态= sended

他们没有得到服务器的任何回复。控制台总是说:'此请求没有可用的响应数据'。 但是像这样的要求很好:

  

/客户/ API /显示/ R:311 NAV =报告

     

/客户/ API /显示/ R:30 NAV =仪表板

     

......

为什么呢?

以下是详细信息:

200

the details (wireshark) about the request

这是我的服务器端代码(PHP):

request ----------------------

var request = $.ajax({
    url: 'customer/api/show/r:' + Math.round(Math.random() * 1000),
    data: params,
    dataType: 'json',
    success: function (res) {
        /* do something, like: update the dom with the res.html */
    },
    error: function() {
    }
});

response ----------------------

General:
Request URL:http://test.local/api/show/r:31?nav=push
Request Method:GET
Status Code:200 OK
Remote Address:127.0.0.1:80

Response Headers:
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html; charset=utf-8
Date:Tue, 17 Jan 2017 08:58:50 GMT
Server:nginx/1.10.0
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Powered-By:PHP/5.5.36

......

" $ this->渲染"方法:

......
ob_start();
$this->render("customer/static/" . $nav . ".php"); /* html with php */
$result->html = ob_get_clean();

echo json_encode($result);

......

PS:

public function render($filename, $output_content=TRUE) {
    global $C, $D;
    $filename = $C->INCPATH . '../html/' . $filename;
    if ($output_content) {
        require($filename);
        return TRUE;
    } else {
        ob_start();
        require($filename);
        $cnt = ob_get_contents();
        ob_end_clean();
        return $cnt;
    }
}

反应正常......

The Screen Shot about this.

0 个答案:

没有答案