fork download
  1. testButton.onclick = function(e) {
  2. let xhr = new XMLHttpRequest();
  3. xhr.open('POST', '/', true);
  4. xhr.setRequestHeader('Conent-Type', 'application/json');
  5. xhr.onreadystateexchange = function () {
  6. if (xhr.readyState ===4 && xhr.status === 200) {
  7. var json_resp = JSON.parse(xhr.responseText);
  8. console.log('SUCCESS');
  9. console.log(json_resp)
  10. }
  11. }
  12. let token = $('input[name=csrfmiddlewaretoken]').val();
  13. let body = JSON.stringify({"name": "Becca", "csrfmiddlewaretoken": token});
  14. console.log($('input[name=csrfmiddlewaretoken]').val());
  15. console.log(body);
  16. xhr.send(body);
  17. console.log('HERE');
  18. };
Runtime error #stdin #stdout #stderr 0.02s 16700KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog.js:1:1 ReferenceError: testButton is not defined
Stack:
  @prog.js:1:1