首页 文章

Ajax Request返回空响应

提问于
浏览
0

我有以下情况:

在我的本地服务器上,我打了这个电话

文件: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调用该操作时,它总是一个空白的响应,并带有以下 Headers :

Request URL: http://debug.xxxxxxx.xxx/admin/banners/repair-broken-banner/

Request Headers CAUTION: Provisional headers are shown.

  • 接受:application / json,text / javascript,/; Q = 0.01

  • Content-Type:application / x-www-form-urlencoded;字符集= UTF-8

  • 原产地:http://debug.xxxxxxx.xxx

  • Referer:http://debug.xxxxxxx.xxx/admin/banners/history-list

  • User-Agent:Mozilla / 5.0(Windows NT 6.1; WOW64)AppleWebKit / 537.36

  • (KHTML,与Gecko一样)Chrome / 32.0.1700.107 Safari / 537.36

  • X-Requested-With:XMLHttpRequest

表格数据

  • pch_id:697f1eaa2fc691a9a7d22d315f7ed8c966febe8ec2c57c1c7a867897f6431dfb8b596ef9dd8f2394c875c638496f7ec9

我认为这可能是一个php错误,但是如果我在第一次脚本调用时写了一条消息并且死了,那么该页面仍然是空白的 . 在apache访问日志中,没有任何跟踪调用 . 我在firefox中尝试过这个调用,它没有出现在XHR选项卡中,就像调用它没有执行一样 .

EDIT: Javascript部分已完成

1 回答

  • 1

    我想你正在使用Adblock plus . 它与Javascript无关,更多与URL本身有关 .

    您在网址中有 Banner 字样 . 请求网址:http://debug.xxxxxxx.xxx/admin/ banners / repair-broken-banner /

    为您的网站停用Adblock plus,它应该可以正常运行 .

相关问题