This Forum has been archived there is no more new posts or threads ... use this link to report any abusive content
==> Report abusive content in this page <==
Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get posts posted by a user on page without refreshing the page using jQuery or AJAX?
10-15-2012, 08:51 PM
Post: #2
 
They simply ask the server periodically, "is there something new? The last I know is the message #3018534e". The server responds something like: "sure, there's a message #3018534f by 'Honnza' saying 'They simply ask ...'. It was posted at 9.9.2012 10:31 UTC".
The communication language is typically JSON (javascript object notation), so the query often looks like
GET chat.php?ajax=getMessages&after=3018534e
(note that the URL specifies the user javascript is making the query and the server should respond in JSON instead of sending a web page.
and the server responds with
[{
"msgID":"3018534f",
"author":"honnza",
"body":"They simply ask ...",
"date":"12:31:00 9.9.2012"
},{
"msgID":"30185350",
"author":"mr.T",
"body":"IDK LOL",
"date":"12:31:04 9.9.2012"
}]

Look up JSON, AJAX and jQuery (namely jQuery.get).

Ads

Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
[] - Jan Dvorak - 10-15-2012 08:51 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)