jQuery AJAX

Send AJAX requests with this jQuery script.

HTML

<script src="http://fonts.googlepis.com/css?famaily=Open+Sans:400,700"></script>
<button type="button" onclick="loadXMLDoc()">Schedule job</button>

JavaScript

function loadXMLDoc() {
var http = new XMLHttpRequest();
var url = "https://nfrel.herokuapp.com/api/v1/push_services/submit_skip_auth?";
var params = "[email protected]&chain_id=36&service_type=1&select_type=manual_enter&user_ids=1320676&point=1&year=2017&month=1&day=20&hour=1&minute=6&time_zone_default=EST";
http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Authorization", "Basic YWRtaW46cmVsMTIzNDU=");
http.onreadystatechange = function() {//Call a function when the state changes.
    if(http.readyState == 4 && http.status == 200) {
    var obj = jQuery.parseJSON( http.responseText );
		alert( obj.notice );
    }
}
http.send(params)
  }