AJAX request not Updating in the UI but updates on the console

353 viewsIssues
0

the voting AJAX request is not updating on the ui while it is updating on the browser network and the console. Pls how can i fix it

function upVote( id) {
  $.ajax({
  type: "POST",
//   url: "/wp-content/plugins/anspress-question-answer/templates/votesystem/scripts.php",
url: "/scripts.php",
  data: {
                // action: 'my_custom_action',
                up: id,
                user: <?php echo $userid; ?>,
                question_id:<?php echo $question_id;?>
            },
  beforeSend: function(){
    $('#links-'+id+' .btn-vote').html("<img src='loaderIcon.gif' height='16px'>");
  },
  success: function(data){ 
    // $('#data').html(data);
    console.log(data);
    console.log(data.data);
$('#up_count'+id).html(data.data.up_count);
  $('#down_count'+id).html(data.data.down_count);
    // alert(data.message);
    // Reload the page after the OK alert
      // location.reload();
      // return false; //This is commented for reload (PPE)
  },
  error: function(error) {
                // Handle errors
                console.log(error);
                alert(error.message);
                // showSnackbar(error.message);
            }
  });
}

Asked question