Advertisement
Guest User

Untitled

a guest
May 3rd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. <input id="clickMe" type="button" value="clickme" onclick="doFunction();" />
  2. <script>
  3.  
  4. xmlhttp = new XMLHttpRequest();
  5. var url = "https://api.parse.com/1/classes/english";
  6. xmlhttp.open("POST", url, true);
  7. xmlhttp.setRequestHeader("Content-type", "application/json");
  8. xmlhttp.setRequestHeader("X-Parse-Application-Id", "VnxVYV8ndyp6hE7FlPxBdXdhxTCmxX1111111");
  9. xmlhttp.setRequestHeader("X-Parse-REST-API-Key","6QzJ0FRSPIhXbEziFFPs7JvH1l11111111");
  10. xmlhttp.onreadystatechange = function () { //Call a function when the state changes.
  11. if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  12. alert(xmlhttp.responseText);
  13. }
  14. }
  15. var parameters = {
  16. "ephrase": "english",
  17. "pphrase": "farsi",
  18. "nvote": 0,
  19. "yvote": 0
  20. };
  21. // Neither was accepted when I set with parameters="username=myname"+"&password=mypass" as the server may not accept that
  22.  
  23. function doFunction() {
  24. xmlhttp.send(parameters);
  25. }
  26.  
  27. </script>
  28.  
  29. xmlhttp.send(parameters);
  30. ^^^^^^^^^^
  31.  
  32. xmlhttp.setRequestHeader("Content-type", "application/json");
  33.  
  34. var xhr = new XMLHttpRequest();
  35. xhr.open("POST", "https://api.victorops.com/api-public/v1/incidents", true);
  36. xhr.setRequestHeader("X-VO-Api-Id", "your api_id");
  37. xhr.setRequestHeader("X-VO-Api-Key", "your api_key");
  38. xhr.setRequestHeader("Content-type", "application/json");
  39. xhr.setRequestHeader("Accept", "application/json");
  40.  
  41. xhr.onreadystatechange = function () {
  42.  
  43. if(xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
  44. console.log(xhr.responseText);
  45. console.log('yes');
  46. };
  47. if (xhr.status != 200) {
  48. console.log( xhr.status + ': ' + xhr.statusText );
  49. console.log('no');
  50. }
  51. };
  52.  
  53. var json = JSON.stringify({
  54. summary: "data from your json",
  55. details: "data from your json",
  56. userName: "data from your json",
  57. targets: [
  58. {
  59. type: "data from your json",
  60. slug: "data from your json"
  61. }
  62. ]
  63. });
  64. xhr.send(json);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement