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