How to auto update data without reloaing page? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to auto update data without reloaing page?

Hello I have a little confusion I had made a chatting website I want that if anyone send anything then it should be uploaded on my webpage without refreshing I mean to say that if anyone is on my website then he can see the message without refreshing the page. (I think it can be done using Ajax)

14th Jul 2019, 2:02 PM
Vikash Tiwari
Vikash Tiwari - avatar
5 Answers
+ 2
Can you please tell me why it is not good practice. On sending the page auto refresh but I want that it keep updating
15th Jul 2019, 10:32 AM
Vikash Tiwari
Vikash Tiwari - avatar
0
try to look for REST API first. https://www.sololearn.com/learn/10391/?ref=app for auto update, you can use setInterval and ajax call
14th Jul 2019, 3:36 PM
Taste
Taste - avatar
0
You could do a simple function that does an ajax-call whenever you hit 'send'. This is probably not best practice, but I'm assuming it's a small project.
14th Jul 2019, 4:18 PM
Roolin
Roolin - avatar
0
Taste can u please write code for me
15th Jul 2019, 10:34 AM
Vikash Tiwari
Vikash Tiwari - avatar
0
I don't truly know if it really is good or bad practice, but I would assume it is a bad practice if you are going to have a lot of users, since the onclick ajax-call is going to be executed every time someone clicks on it. Imagine if you have several hundred people clicking the button multiple times. It could break or slow down your program. I would assume a good practice would ensure that each request would be handled a bit more delicate, but I cannot answer your question on good practice since I've never worked on a project with a huge user base.
15th Jul 2019, 10:47 AM
Roolin
Roolin - avatar