簡體   English   中英

Ajax請求返回的響應為空

[英]Ajax Request returns with an empty response

我有以下情況:

在我的本地服務器上,我撥打了電話

文件:history.js

$(document).ready(function() {
    $('button[data-pid]').click(function() {
        $.ajax({
            cache: false,
            data: JSON.stringify({ pch_id: $(this).data('pid') }),
            dataType: 'json',
            type: 'POST',
            url: REPAIR_BROKEN_BANNER_URL
        }).done(function(data) {

            $('#fix-broken-banner-text').text(data.message);

            if (!data.error) {
                $('#fix-broken-banner-modal').on('hidden.bs.modal', function() {
                    window.location.href = window.location.href;
                });
            }

            $('#fix-broken-banner-modal').modal('show');

        }).fail(function() {
            $('#fix-broken-banner-text').text(REPAIR_BROKEN_ERR_GENERIC);
            $('#fix-broken-banner-modal').modal('show');
        });
    });
});

頁面包含

<script type="text/javascript" src="/js/history.js"></script>
<script type="text/javascript">
    var REPAIR_BROKEN_BANNER_URL = '/admin/banners/repair-broken-banner/';
    var REPAIR_BROKEN_ERR_GENERIC = 'Unable to perform the action';
</script>

服務器始終以JSON響應,但仍然發生錯誤。

問題出在生產服務器上。 (生產服務器是帶有Debian的虛擬服務器)。 當ajax調用該動作時,它總是得到一個空白響應,帶有以下標頭:

要求網址: http : //debug.xxxxxxx.xxx/admin/banners/repair-broken-banner/

請求標頭警告:顯示了臨時標頭。

  • 接受:application / json,text / javascript, / Q = 0.01
  • 內容類型:應用/ X WWW的窗體-urlencoded; 字符集= UTF-8
  • 來源: http//debug.xxxxxxx.xxx
  • 引薦來源: http//debug.xxxxxxx.xxx/admin/banners/history-list
  • 用戶代理:Mozilla / 5.0(Windows NT 6.1; WOW64)AppleWebKit / 537.36
  • (KHTML,例如Gecko)Chrome / 32.0.1700.107 Safari / 537.36
  • X-要求 - 由於:XMLHttpRequest的

表格數據

  • pch_id:697f1eaa2fc691a9a7d22d315f7ed8c966febe8ec2c57c1c7a867897f6431dfb8b596ef9dd8f2394c875c638496f7ec9

我以為這可能是php錯誤,但是如果我寫一條消息而在第一個腳本調用中死了,該頁面將保持空白。 在apache訪問日志中,沒有該呼叫的蹤跡。 我已經在firefox中嘗試過此調用,但它並未出現在XHR選項卡中,好像未執行該調用一樣。

編輯: Javascript部分已完成

我想您正在使用Adblock plus。 它與Javascript無關,而與URL本身有關。

您在URL中有橫幅詞。 要求網址: http : //debug.xxxxxxx.xxx/admin/ 橫幅 / repair-broken-banner /

為您的網站禁用Adblock plus,它應該可以正常工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM