Skip to content

Instantly share code, notes, and snippets.

@steveharoz
Created June 27, 2016 22:55
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 steveharoz/3d6f56223f33a2f98f651234395e803e to your computer and use it in GitHub Desktop.
Save steveharoz/3d6f56223f33a2f98f651234395e803e to your computer and use it in GitHub Desktop.
request success despite failure

Run this file on your local machine without a web server

It should fail because (a) chrome doesn't allow requests on a local machine (b) submit.php doesn't exist (or shouldn't in this directory)

But it claims to succeed!

<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script>
function callback() { console.log("SUCCESS... even though success is impossible because the file doesn't exist"); }
d3.xhr('submit.php', 'application/x-www-form-urlencoded', callback)
.header('content-type', 'application/x-www-form-urlencoded')
.post('data=' + encodeURIComponent(JSON.stringify({hello: "world"}, null, " ")))
.on('error', function (error) {
console.log('ERROR: ' + error);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment