[英]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/
請求標頭警告:顯示了臨時標頭。
表格數據
我以為這可能是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.