Search code examples
ajaxjquerytimeagoabbr

Timeago not working in ajax call


I an using this plugin for calculate timeago, it is not working when i load content by ajax call.

I have created 2 fiddle for this,Please check working fiddle and not working fiddle

Can anyone tell me what is wrong with second one?


Solution

  • your html param in your post data is a mess:

    html: "<abbr title="2013-06-21T12:57:04+0530" class="timeago">
            2013-06-21 12:57:04
        </abbr>"."<abbr title="2013-06-22T11:17:26+0530" class="timeago">
        2013-06-22 11:17:26
    </abbr>",
    

    should be:

    html: "<abbr title=\"2013-06-21T12:57:04+0530\" class=\"timeago\">2013-06-21 12:57:04</abbr>"+"<abbr title=\"2013-06-22T11:17:26+0530\" class=\"timeago\">2013-06-22 11:17:26</abbr>"
    

    You are using quotes to encase your html string, but not escaping the quotes used in the html itself - and it appears you were trying to use a . to concat the string, in javascript you should use a +.

    Though, the formatting is weird after that fix, it works.