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:43 PM
Post: #1
How to get posts posted by a user on page without refreshing the page using jQuery or AJAX?
I am trying to make a wall posting system something like facebook.
I made all the things and it is almost working good.
When a user post something, that prepend on this user page who is posting but the other users
who are his friends, they need to refresh the page and then they get those posts.
I want that when a user post something, it should also prepend on the other users page same time.
I also realize that javascript is not the server side language, but how facebook and other websites are doing that.
Any solution?
Thanks in Advance.

Ads

Find all posts by this user
Quote this message in a reply
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 


Forum Jump:


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