jQuery AJAX

Send AJAX requests with this jQuery script.

by Sivasakthi Chandrasekaran

HTML

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

<p id="demo"></p>

CSS

body{
    font-family: 'Open Sans', 'Helvetica Neue', 'Arial', sans-serif;
    font-size: 13px;       
}

form span{  
    display: block;
    margin: 10px;
}

label{
    display: inline-block;
    width: 100px;     
}

input[type="text"]{
    border: 1px soild #ccc;
    width: 200px;
    padding: 5px;
}

input[type="submit"]{
     padding: 5px 15px;       
}

span#result{
    padding: 5px;
    background: #ff9;        
}

img#loadingimg{
    display: none;                   
}

JavaScript

function loadXMLDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("demo").innerHTML =
      this.responseText;
    }
  };
  xhttp.open("POST", "http://nfrel.herokuapp.com/api/v1/push_services/[email protected]&chain_id=70&service_type=1&select_type=manual_enter&user_ids=350427&point=11&year=2016&month=11&day=29&hour=01&minute=01&time_zone_default=EST", true);
  xhttp.send();
}