Question

Jquery:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/timeago.js" ></script>

$(document).ready(function(){
   jQuery("abbr.timeago").timeago();
});

html:

<abbr class="timeago" title="2008-07-17T09:24:17Z">July 17, 2008</abbr>
function Refresh() {
    setTimeout(function(){      
        <?php echo 'var id = '.json_encode($_GET['id']).';'; ?>
        $('#cmdz').load('cmdajax.php?id='+id);  
    },1000);
}

The #cmdz div contains the abbr tag. timeago working properly in onload but when the div is refreshed it won't works.

for some reason jQuery("abbr.timeago").timeago(); function not working. Here you can find full code:after ajax call jquery function not working properly

Was it helpful?

Solution

Working demo http://jsfiddle.net/FFeE3/1/

Can you please try sourcing your time ago.js from below link and any particular reason you are using jQuery("abbr.timeago").timeago(); you can use $("abbr.timeago").timeago();

Hope this helps rest demo should give you more idea. cheers

Script

  <script type='text/javascript' src="https://github.com/petersendidit/jquery-timeago/raw/master/jquery.timeago.js"></script>

code

$("abbr.timeago").timeago();​

OTHER TIPS

Try out Livestamp.js. It's unobtrusive and auto-updating. All you need to provide is the Unix timestamp.

Two way of representation, Do this way or other way but don't mix:-

jQuery(document).ready(function() {
  jQuery("abbr.timeago").timeago();
});

OR

$(document).ready(function() {
  $("abbr.timeago").timeago();
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top