Tuesday, 15 January 2013

java - Efficient way to implement Likes features in a video application -



java - Efficient way to implement Likes features in a video application -

i have video based project.in project want implement likes features.that there hyperlink on each video total count , when user click on hyperlink after hyperlink hide , show liked text total count of video.

i have write code in javascript ajax main problem in 1 session if user 5 video 5 times db hit.is there efficient way implement it.

<div id="status${video.id}"><a href="javascript:calllike('${video.id}');"> like- </a> </div><a id="like1${video.id}" style="color:#ffffff;">${video.likescount}</a> function calllike(id) { document.getelementbyid("like"+id).innerhtml='300'; var postdata = '?id='+id; var url =protocol+'//'+host+'/xxx/getlike'+postdata; // alert("url:"+url); if (window.xmlhttprequest) { req = new xmlhttprequest(); } else if (window.activexobject) { req = new activexobject("microsoft.xmlhttp"); } req.onreadystatechange = likesres; req.open("post", url, true); req.send(null); } function likesres() { if (req.readystate == 4) { if (req.status == 200){ response = req.responsetext; document.getelementbyid("like1"+id).innerhtml=response; document.getelementbyid("status"+id).innerhtml='liked--'; } }

java javascript ajax like social

No comments:

Post a Comment