[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/wsr/ - Worksafe Requests

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


Janitor application acceptance emails are being sent out. Please remember to check your spam box!


[Advertise on 4chan]


File: notcord.png (278 KB, 1335x814)
278 KB
278 KB PNG
I'm making a chat app but it still needs one thing.
It updates the messages every x seconds, but I need to make it so that it only checks for new messages every x seconds and only refreshes the post area div if there is new content.
How do I achieve dat?

For some reason the "textstatus notmodified" thing doesn't work.
mail_getposts.php contains a while loop that fetches posts from the SQL table.
>>
>>1549319
i think that the "textstatus notmodified", refers to headers which are said from server when it's sending cache header and Last-Modified or ETag headers.
refer to ifModified in https://api.jquery.com/jquery.ajax/
On its own it doesn't know the page that is sent is different, you would need to set appropriate headers in the php script, for that you would need to have server side logic, which would remember what was already sent which is imho quite complicated
The best would imho be to send new messages in json, and append them client side (that would make easy knowing stuff like timestamp of last message)
if you insist on keep doing it with sending html, instead of refreshing with new content, first load existing messages and then have different php script with timestamp argument which is asked every X seconds if there were any new messages in last X seconds (i.e. newer than current time - X seconds) and if there are any, append them to the #postarea instead of replacing it (though with sending html without parsing it client side, you risk having duplicate or missed messages if they come near the X second threshold)
>>
>>1549337
>for that you would need to have server side logic, which would remember what was already sent which is imho quite complicated
nevermind, that's stupid
on second thought you can probably just set Last-Modified header to timestamp of last message



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.