Skip to content

Instantly share code, notes, and snippets.

@mbostock
Created June 27, 2016 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbostock/b11689abe3db2fb7d90f90e5eb81a8b5 to your computer and use it in GitHub Desktop.
Save mbostock/b11689abe3db2fb7d90f90e5eb81a8b5 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<meta charset="utf-8">
<script src="//d3js.org/d3.v4.0.0-rc.2.min.js"></script>
<script>
// This fails without an error because it fails synchronously,
// and the error handler isn’t registered until AFTER the request is sent.
d3.request("invalid:///url")
.on("load", function() { console.log("1 loaded"); })
.post()
.on("error", function() { console.log("1 errored"); });
// If you register before the sending the request, you’ll see the error.
d3.request("invalid:///url")
.on("load", function() { console.log("2 loaded"); })
.on("error", function() { console.log("2 errored"); })
.post();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment