Hi, first of all let me thank anyone willing to help out with this. Jquery / Ajax update Span or Div by ID without refreshing page
<?php
}
$select = $DatabaseCo->dbLink->query("select sh_id from shortlist where to_id='" . $Row->matri_id . "' and from_id='" . $user_id . "'");
if (mysqli_num_rows($select) == 0) {
?>
<a class="bis-cursor <?php
if (isset($_SESSION['user_id'])) {
echo "addToshort-link";
}
?>" id="<?php echo $Row->matri_id; ?>" title="Add to Shortlist">
<h6 class="mlm text-black-1 pb-2">Add to Shortlist</h6></a>
<?php } else { ?>
<a class="bis-cursor f5 <?php
if (isset($_SESSION['user_id'])) {
echo "addToblock-link";
}
?>" id="<?php echo $Row->matri_id; ?>" title="Remove From Shortlist">
<h6 class="mlm text-black-1 pb-2">Remove Shortlist</h6></a>
<?php } ?>
==========================================================
My jquery code
========================================================
$('.addToblock-link').click(function () {
$('#shortdiv').hide();
});
$(function() {
$(".addToblock-link").click(function(e) {
e.preventDefault();
var commentContainer = $(this).parent();
var id = $(this).attr("id");
var string = 'id='+ id ;
$.ajax({
type: "POST",
url: "addshortlist",
data: string,
cache: false,
success: function(){
$("#loaderID-2").css("opacity",1);
$("#loaderID-2").css("z-index",9999);
$('#loaderID-2').html('<div class="success-msg-1"> <div class="rmr"><div class="mark-circle"><div class="background"></div><div class="mark draw"></div></div></div></div>');
setTimeout(function() {
e.preventDefault();
$("#loaderID-2").css("opacity",0);
$("#loaderID-2").css("z-index",-1);
}, 2000); location.reload();
}
});
return false;
});
});
$('.addToshort-link').click(function () {
$('#shortdiv').hide();
});
$(function() {
$(".addToshort-link").click(function() {
$('#shortdiv').fadeIn();
var commentContainer = $(this).parent();
var id = $(this).attr("id");
var string = 'add_id='+ id ;
$.ajax({
type: "POST",
url: "addshortlist",
data: string,
cache: false,
success: function(){
$("#loaderID-2").css("opacity",1);
$("#loaderID-2").css("z-index",9999);
$('#loaderID-2').html('<div class="success-msg-1"> <div class="rmr"><div class="mark-circle"><div class="background"></div><div class="mark draw"></div></div></div></div>');
setTimeout(function() {
$("#loaderID-2").css("opacity",0);
$("#loaderID-2").css("z-index",-1);
}, 2000); location.reload();
}
});
return false;
});
});