assets/js/script.js
/**
 * This Function is Called When The User Pressed The Love Post Button
 */
This Function is Called When The User Pressed The Love Post Button
This Function is Called When The User Pressed The Love Post Button
function love_post(post_id) {
  var request = new XMLHttpRequest();
  request.onreadystatechange = function () {
    if (this.readyState == 4 && this.status == 200) {
      var response = JSON.parse(this.responseText);
      document.querySelector('.view-modal .content .info .modal-actions .likes .nth-likes').innerHTML = response.likes;
      document.querySelector('.view-modal .content .info .modal-actions .likes i').setAttribute('class', response.class);
    }
  }
  request.open('POST', window.location.origin + '/laquatat/ajax_requests/love_post.php', true);
  request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  request.send('post_id=' + post_id);
}
function love_post ( post_id ) { var request = new XMLHttpRequest ( ) ; request . onreadystatechange = function ( ) { if ( this . readyState == 4 && this . status == 200 ) { var response = JSON . parse ( this . responseText ) ; document . querySelector ( '.view-modal .content .info .modal-actions .likes .nth-likes' ) . innerHTML = response . likes ; document . querySelector ( '.view-modal .content .info .modal-actions .likes i' ) . setAttribute ( 'class' , response . class ) ; } } request . open ( 'POST' , window . location . origin + '/laquatat/ajax_requests/love_post.php' , true ) ; request . setRequestHeader ( 'X-Requested-With' , 'XMLHttpRequest' ) ; request . setRequestHeader ( 'Content-Type' , 'application/x-www-form-urlencoded' ) ; request . send ( 'post_id=' + post_id ) ; }
This Function is Called When The User Pressed The Love Post Button
This Function is Called When The User Pressed The Love Post Button
// Send a New Request To Love Post Page
 // If The Request is OK
 // Get Returned Data in a JSON Format
 // Change The Likes Number
 // Add Class to The Like Button According to The User Action
 // Send The Request
