ajax poker,javascript - Ajax Request returns with an empty response - Stack Overflow

在本地服务器上,一个Ajax调用能正常工作,但在生产环境中遇到问题,总是返回空白响应。请求头显示为预期的JSON类型,但服务器日志中没有调用记录。尝试在PHP中添加错误消息并终止脚本,页面仍然空白。此问题可能涉及到服务器配置、PHP错误处理或跨域问题。
摘要由CSDN通过智能技术生成

I've got the follow situation:

On my local server I made this call

File: 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');

});

});

});

Page inclusion

var REPAIR_BROKEN_BANNER_URL = '/admin/banners/repair-broken-banner/';

var REPAIR_BROKEN_ERR_GENERIC = 'Unable to perform the action';

The server responds always with a JSON, still it happened an error.

The issue is on the production server. (Production server is a virtual server with Debian). When the ajax call the action, it gets always a blank response, with the follow headers:

Request Headers CAUTION: Provisional headers are shown.

Accept:application/json, text/javascript, /; q=0.01

Content-Type:application/x-www-form-urlencoded; charset=UTF-8

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

(KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36

X-Requested-With:XMLHttpRequest

Form Data

pch_id:697f1eaa2fc691a9a7d22d315f7ed8c966febe8ec2c57c1c7a867897f6431dfb8b596ef9dd8f2394c875c638496f7ec9

I thought it could be a php error, but If I write a message and die at the first script call, the page remains blank. In the apache access logs there's no trace of the call.

I've tried this call in firefox and it doesn't appear into the XHR tab, as though the call it's not performed.

EDIT: Javascript part is complete

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值