Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1027 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Need help with AJAX comments.

Thread title: Need help with AJAX comments.
Closed Thread    
    Thread tools Search this thread Display Modes  
04-17-2006, 08:22 PM
#1
Nick is offline Nick
Status: Junior Member
Join date: Jul 2004
Location: Pittsburgh
Expertise:
Software:
 
Posts: 65
iTrader: 0 / 0%
 

Nick is on a distinguished road

Send a message via AIM to Nick

  Old  Need help with AJAX comments.

I am creating a script that allows members to post comments, and I would like to do so through the use of AJAX. What I need help with is how to only load new comments from the database, while preserving what is already displayed.

04-19-2006, 09:49 AM
#2
echoSwe is offline echoSwe
Status: Member
Join date: Jul 2005
Location:
Expertise:
Software:
 
Posts: 185
iTrader: 0 / 0%
 

echoSwe is on a distinguished road

  Old

Basically you just need a page to call from client-side, that, given the correct parameters (entry id) and context (session) will respond with your data; either in JSON format, plain text or XML format.

04-19-2006, 06:55 PM
#3
Nick is offline Nick
Status: Junior Member
Join date: Jul 2004
Location: Pittsburgh
Expertise:
Software:
 
Posts: 65
iTrader: 0 / 0%
 

Nick is on a distinguished road

Send a message via AIM to Nick

  Old

echoSwe, I know how to retrieve the information, but what I'm asking is what is a good way to retrieve comments (since last reload in AJAX). Basically, I need a way to send back along with the comments a timestamp, have the page read the timestamp, and make a new AJAX call sending out the timestamp (so the php knows what comments have been posted since last reload).

04-20-2006, 11:30 AM
#4
echoSwe is offline echoSwe
Status: Member
Join date: Jul 2005
Location:
Expertise:
Software:
 
Posts: 185
iTrader: 0 / 0%
 

echoSwe is on a distinguished road

  Old

Well, you could simply give your page an xml snippet:
Code:
<entries timestamp="2005-02-03 22:33">
<entry>
    <name>Kalle</name>
    <datetime>2006-05-01 22:33</datetime>
    <content><![CDATA[
Hej

Lalala]]></content>
</entry>
<entry>
<name>Nils Petter</entry>
<datetime>... and so on</datetime>
<content/>
</entry>
</entries>
Then on your client side, initiate an XML parser within a function that returns the parser object - as described for Firefox: http://www.pcquest.com/content/codin.../104080302.asp
and for IE: http://www.xmlfiles.com/dom/dom_parser.asp
- because once you got your parser object, you can use the DOM to parse it.

The timestamp can be read off the attribute on the top. The xml-file is automatically generated from the ASP.Net page or PHP page that you place your calls to... The timestamp is updated every request and also sent along when placing a request.

Did this help?

04-20-2006, 07:15 PM
#5
Nick is offline Nick
Status: Junior Member
Join date: Jul 2004
Location: Pittsburgh
Expertise:
Software:
 
Posts: 65
iTrader: 0 / 0%
 

Nick is on a distinguished road

Send a message via AIM to Nick

  Old

I believe this should do it, thanks. I don't have time to test it now though, but it appears as though it should work. I'll let you know once I get a chance to test it.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed