0

This test works, but is there a better way than loading an empty file, to run an async javascript function?

$.ajax({
    type: "POST",
    url: "empty.dat", // empty file

    success: function(){
        doSomething(); // function to be run   
    },
    error: function(){
        alert("error");
    }
});
Baked Inhalf
  • 3,375
  • 1
  • 31
  • 45

1 Answers1

4

Depending on the browsers you need to target, you can use any of setTimeout(fn, 0), setImmediate(fn) or Web Workers.

Phylogenesis
  • 7,775
  • 19
  • 27