Skip to content

Instantly share code, notes, and snippets.

@steveharoz
Created June 27, 2016 22:55

Revisions

  1. steveharoz created this gist Jun 27, 2016.
    7 changes: 7 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    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!
    12 changes: 12 additions & 0 deletions test.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    <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>