开发者

post last messages YouTube comments function

I saw this new开发者_Python百科 YouTube function from their video comments where it shows a link that says "2 messages have been posted since you arrived", so this basically uses an ajax request which keeps requesting the database since the date you arrived on the page but how can this be done since you must have the date of your arrival inside this ajax request which keeps on updating itself and changing your date of arrival to NOW?


The internal latest_time variable is updated each time the AJAX request is sent.

The response is like this:

<?xml version="1.0" encoding="utf-8"?>
<root>
 <poll_delay>
  <![CDATA[15000]]>
 </poll_delay>
 <latest_time>
  <![CDATA[1289325319]]>
 </latest_time>
 <return_code>
  <![CDATA[0]]>
 </return_code>
 <comments>
  <![CDATA[]]>
 </comments>
</root>

, the latest_time is stored on the client side and used in the next request.


Ok so I finally used php session to store the date variable, this way the variable isnt affected when inserted in the ajax request wich constantly reloads itself(the variable keeps its unique value(the time the user arrived on the page) , you can also use a variable selected from a database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜