1

The following AJAX request works fine in Google Chrome but not in Mozilla Firefox. No hit on the target URL and no errors in the console. If I output the data from the error function I get a status code is 0 and text "error".

I've noticed that if the Ajax request URL is the same as the page's URL, it works fine.

Page URL: http://www.somedomain.com/admin/stats/

$.ajax({
    url: '/admin/banners/banner_details/'+ bannerCampaignId + '?v=' + scriptVersion,
    method: 'POST',
    dataType: 'html',
    data: {
        'data[Stats]' : 'true',
        'data[Banner][channel]' : channel,
        'data[Banner][start_date]' : startDate,
        'data[Banner][end_date]' : endDate,
        'data[BannerCampaign][company_id]' : 'false'
    },
    success: function(html){
        console.log('success');
    },
    error: function(data){
        console.log('error');
        console.log(data);
    }
});

/admin/banners/banner_details/ : doesn't work
/admin/stats/banner_details/ : works

The response data is exactly the same.

I'm using jQuery v1.9.1, Google Chrome v61, Mozilla Firefox v56

Shiladitya
  • 12,003
  • 15
  • 25
  • 38

1 Answers1

1

Turns out it was the browser's Ad blocker that caused the issue because the URL contains the word "banners".

  • either you replace that word or use Javascript code that detects Adblock, please see https://stackoverflow.com/a/24111206/2516718 – derloopkat Oct 18 '17 at 08:59
  • Thanks for the advice. It will cost too much refactoring to replace the word. Will build in a check that detects Ad Blockers. – Riaan Van Staden Oct 18 '17 at 11:03