I'm using setInterval to read a log that is updated frequently. However, if I want to select the text it displays from the log, when it refreshes it, I cannot select the text because of it refreshing. So my question here would be, how do I make this load ONLY when a new entry is created?
Would you rather keep the selection even after it changes? You can do that. Google around for selection ranges: something like document.createRange() and some object.getSelection() I think.
Otherwise don't .html() unless the data != the current value. Or put something in the AJAX business that keeps track of, say, last-updated timestamps, and indicates in the returned data whether the thing (timestamp) has changed.
What about instead of updating the entire #log element, you could insert a new <p> or <li> element? If you animate the inserted element with .slideDown(), you don't have to worry about the scroll height. Unless you are trying to put it in a textarea or something. I wouldn't put the log text in a textarea
I'd send along a timestamp of your last poll when you call log.php. log.php can then only send you the entries that have been entered since that timestamp. Rather than using .html(), append the new entries to the #log element. Then your selection won't be affected.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.