Jquery Ajax call not loading always -
i have link when clicked pops div , collects data page through ajax call , loads data in div after success. problem this, when pop div , data loads, close div. when click link pop div again , reload data data doesn't load, doesn't sends ajax call shows me previous data loaded in div before close it. want achieve when ever div closed , link clicked again, ajax call sent php page , reloads new data link pops div <a href="javascript:;" onclick="showlikes('<?php echo $id; ?>')">likes</a>
. , here ajax call:
function showlikes(x){ document.getelementbyid('#likediv').style.display='block'; $.ajax({ type: "get", url: "/get_likes.php?id="+x, beforesend: function(){ document.getelementbyid('#beforesendimg').style.display='block'; }, success: function(data){ document.getelementbyid('#beforesendimg').style.display='none'; likes = $(data).fadein(800); $("#likediv").html(likes); }, }); }
please knows how better?
try;
function showlikes(x){ $('#likediv').css({'display:'block'}).html(""); $.ajax({ type: "get", url: "/get_likes.php, data: {id: x}, beforesend: function(){ $('#beforesendimg').css({'display':'block'}); }, success: function(data){ $('#beforesendimg').css({'display':'none'}); likes = $(data).fadein(800); $("#likediv").html(likes); }, }); }
Comments
Post a Comment