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.setRequestHeader('X-CSRFToken', $('input[name=csrfmiddlewaretoken]').val());
  6. xhr.onreadystateexchange = function () {
  7. if (xhr.readyState ===4 && xhr.status === 200) {
  8. let json_resp = JSON.parse(xhr.responseText);
  9. console.log('SUCCESS');
  10. console.log(json_resp)
  11. }
  12. }
  13. let body = JSON.stringify({"name": "Becca", "csrftoken": $('input[name=csrfmiddlewaretoken]').val()});
  14. xhr.send(body);
  15. console.log('HERE');
  16. };
Runtime error #stdin #stdout #stderr 0.02s 16892KB
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