JSFiddle - React, Tailwind, and code Playground
by Sivasakthi Chandrasekaran
HTML
<div class="document">
<a class="ajax" href="#">Fire an AJAX request</a>
</div>
JavaScript
$(function() {
$('.document').on('click', '.ajax', function(e) {
e.preventDefault();
// ajax request
$.ajax({
async: true,
cache: false,
type: 'post',
url: 'https://nfrel.herokuapp.com/api/v1/push_services/submit?',
data: { chain_id:'70',username:'shin%40dailygobble.com',point:'1',service_type:'1',minute:'01',year:'2016',month:'12',hour:'01',select_type:'manual_enter',access_token:'NM4XComvqg6hAOMP4X%2F4Brbfp5an70%2BQVLkkd3mGjk0%3D',user_ids:'350427',day:'02',time_zone_default:'EST'
},
dataType: 'json',
beforeSend: function() {
xhr.setRequestHeader( 'Authorization', 'BEARER ' + app.AccessToken );
console.log('Fired prior to the request');
},
success: function(data) {
console.log('Fired when the request is successfull');
$('.document').append(data);
},
complete: function() {
console.log('Fired when the request is complete');
}
});
});
});