0

I have several ajax requests I'm making using jQuery. The requests "go through" fine in Chrome, but in FireFox they all return as an error. The error isn't anything, just "error." It's not a cross-origin request.

They work in FF if I set async: false which obviously I don't want to do. The only workaround I found was to wrap the calls in a setTimeout() function with a 1 ms delay. 1 ms!! And the calls work as expected.

The problem is similar to another question, but I want to know why it fails without setTimeout(). Is there another option I'm missing?

setTimeout(function () {
  $j.ajax({
    url: '/same/server/',
    method: method,
    headers: {
      "Content-Type": "application/json",
      "Accept": "application/json"
    },
    data: data,
    error: function (err, status, errorThrown) {},
    success: function (data) {}
    }
  })
}, 1)
Grant
  • 1,822
  • 1
  • 21
  • 30
  • What have you found in browser dev tools? Does the request get send at all, how does it get answered, …? – CBroe Sep 05 '17 at 07:35
  • @CBroe from what I can tell in the network tool in FireFox, the request doesn't send at all, but the `error` callback gets called in the `$.ajax()` options object – Grant Sep 05 '17 at 07:57

0 Answers0