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 |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
How to get posts posted by a user on page without refreshing the page using jQuery or AJAX? - Sultan - 10-15-2012, 08:43 PM
[] - Jan Dvorak - 10-15-2012 08:51 PM
|
User(s) browsing this thread: 1 Guest(s)