JSFiddle - React, Tailwind, and code Playground
by dshilkret
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<button>
click
</button>
<div id="response">
test
</div>
JavaScript
function createRec()
{
var requestBody = "{\"short_description\":\"Dogs2\"}";
var client=new XMLHttpRequest();
client.open("post","https://dev29198.service-now.com/api/now/table/incident");
client.setRequestHeader('Accept','application/json');
client.setRequestHeader('Content-Type','application/json');
//Eg. UserName="admin", Password="admin" for this code sample.
client.setRequestHeader('Authorization', 'Basic '+btoa('admin'+':'+'Felicity1!'));
client.onreadystatechange = function() {
if(this.readyState == this.DONE) {
document.getElementById("response").innerHTML=this.status + this.response;
}
};
client.send(requestBody);
}
$(document).ready(function(){
$("button").click(function(){
createRec();
});
});