
Gabriel F. answered 11/25/19
Full Stack Software Developer and Mentor
Hi there. You can scroll to bottom after the ajax response but keeping it scrolled to bottom may not be a good idea because the user may want to read previous messages.
There are different scroll methods but I think you are looking for this "element.scrollIntoView()" where "element" is the html tag that contains the last message received. So you just need to call the method on the element that has the last message after the ajax call is completed.
This is from the MOZ docs:
TheElement
interface'sscrollIntoView()
method scrolls the element's parent container such that the element on whichscrollIntoView()
is called is visible to the user
I hope this helps.