Reputation: 390
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
<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>
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 URL: http://debug.xxxxxxx.xxx/admin/banners/repair-broken-banner/
Request Headers CAUTION: Provisional headers are shown.
Form Data
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
Upvotes: 0
Views: 2160
Reputation: 116
I suppose you are using Adblock plus. It has nothing to do with the Javascript, and more to do with the URL itself.
You have the word banners in the URL. Request URL: http://debug.xxxxxxx.xxx/admin/banners/repair-broken-banner/
Disable Adblock plus for your site, and it should work flawlessly.
Upvotes: 1