Regina Miller Regina Miller - 9 months ago 36
Ajax Question

How to make a ajax div just text?

I wish to make this line

$(".load-more").text("No more.");
text only not clickable link like load more.

How can I get that to happen if someone could help?

<script type="text/javascript">
$(document).ready(function(){
// Load more data
$('.load-more').click(function(){
var row = Number($('#row').val());
var catid = Number($('#catid').val());
var allcount = Number($('#all').val());
row = row + <?php echo $records_per_page; ?>;
if(row <= allcount){
$("#row").val(row);
$.ajax({
url: '<?php echo DIR; ?>getCat.php',
type: 'post',
data: {row:row,catid:catid},
beforeSend:function(){
$(".load-more").text("Loading...");
},
success: function(response){
// Setting little delay while displaying new content
setTimeout(function() {
// appending posts after last post with class="post"
$(".post:last").after(response).show().fadeIn("slow");
var rowno = row + <?php echo $records_per_page; ?>;
// checking row value is greater than allcount or not
if(rowno > allcount){

// Change the text and background
$(".load-more").text("No more.");
$('.load-more').css("background","#FB0925");
}else{
$(".load-more").text("Load more.");
}
}, 2000);
}
});
}else{
$('.load-more').text("Loading...");
// Setting little delay while removing contents
setTimeout(function() {
// When row is greater than allcount then remove all class='post' element after 3 element
$('.post:nth-child(3)').nextAll('.post').remove().fadeIn("slow");
// Reset the value of row
$("#row").val(0);
// Change the text and background
$('.load-more').text("Load more");
$('.load-more').css("background","#333333");
}, 2000);
}
});
});
</script>


I am not too familiar with ajax so hope you guys do not mind helping out in it.

thanks

Answer Source

after

$(".load-more").text("No more.");

put this:

$('.load-more').css( 'pointer-events', 'none' );
$('.load-more').click(function(){return false;});
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download