Advertisement
s243a

rest_test_ff2.js

Nov 11th, 2018
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var xhr = new XMLHttpRequest();
  2. //var xhr = bla.XMLHttpRequest();
  3. xhr.open("post", "http://127.0.0.1:8082/KSK/insert", true);
  4. xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
  5. window.console.log("hi");
  6. xhr.onreadystatechange  = function () {
  7.     //document.write(xhr.responseText)
  8.     window.console.log("Entering Callback")
  9.     window.console.log(xhr.responseText)
  10.     //print(xhr.responseText());
  11. };
  12.  
  13. window.console.log("making json data")
  14. var data={"message":"This is a test message",
  15.           "ksk":"testtest12345678",
  16.           "host":"192.168.1.2", //Optional argument. Default = "127.0.0.1"
  17.           "port":9481}; //OPtional argument. Default = 9481
  18. window.console.log("Ready to send");
  19.   // send the collected data as JSON
  20. xhr.send(JSON.stringify(data));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement