Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <input id="clickMe" type="button" value="clickme" onclick="doFunction();" />
- <script>
- xmlhttp = new XMLHttpRequest();
- var url = "https://api.parse.com/1/classes/english";
- xmlhttp.open("POST", url, true);
- xmlhttp.setRequestHeader("Content-type", "application/json");
- xmlhttp.setRequestHeader("X-Parse-Application-Id", "VnxVYV8ndyp6hE7FlPxBdXdhxTCmxX1111111");
- xmlhttp.setRequestHeader("X-Parse-REST-API-Key","6QzJ0FRSPIhXbEziFFPs7JvH1l11111111");
- xmlhttp.onreadystatechange = function () { //Call a function when the state changes.
- if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
- alert(xmlhttp.responseText);
- }
- }
- var parameters = {
- "ephrase": "english",
- "pphrase": "farsi",
- "nvote": 0,
- "yvote": 0
- };
- // Neither was accepted when I set with parameters="username=myname"+"&password=mypass" as the server may not accept that
- function doFunction() {
- xmlhttp.send(parameters);
- }
- </script>
- xmlhttp.send(parameters);
- ^^^^^^^^^^
- xmlhttp.setRequestHeader("Content-type", "application/json");
- var xhr = new XMLHttpRequest();
- xhr.open("POST", "https://api.victorops.com/api-public/v1/incidents", true);
- xhr.setRequestHeader("X-VO-Api-Id", "your api_id");
- xhr.setRequestHeader("X-VO-Api-Key", "your api_key");
- xhr.setRequestHeader("Content-type", "application/json");
- xhr.setRequestHeader("Accept", "application/json");
- xhr.onreadystatechange = function () {
- if(xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
- console.log(xhr.responseText);
- console.log('yes');
- };
- if (xhr.status != 200) {
- console.log( xhr.status + ': ' + xhr.statusText );
- console.log('no');
- }
- };
- var json = JSON.stringify({
- summary: "data from your json",
- details: "data from your json",
- userName: "data from your json",
- targets: [
- {
- type: "data from your json",
- slug: "data from your json"
- }
- ]
- });
- xhr.send(json);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement