Jump to content

Updating info constantly causes <textarea> to randomly skip some of typer characters


rain13

Recommended Posts

Hello.I use window.setInterval to constantly call function that updates info from server using XMLHttpRequest. The strange problem with that is that it causes textarea to miss some characters as you type. however if I replace code that gets new info from server with code that just returns 0, then it works nicely.What's more interesting is that only firefox seems to have this problem.Here you can try to type something (use firefox):

<link removed to minimize traffic from searchengines>

Edited by SoItBegins
Link to comment
Share on other sites

I noticed that you have set the async param to false. That means the page is constantly being blocked each time the interval callback function runs to make the AJAX request. Combined with how often you are sending requests, its bound to create a bottleneck.

Edited by thescientist
  • Like 1
Link to comment
Share on other sites

Yeah, I decreased that time to 500 to make that effect greater. It was normally 3000, but that didn't cause noticeable txet loss so I decreased that time for this demo only. the interesting thing is that other than firefox doesn't seem to have problem with that.

Link to comment
Share on other sites

Because it's general code that gets unread PM count. It's actually in main.html file into which text editor is read. I wrote html parser that allows you to replace placeholders with other file so I have main file that defines general look of page and then I load text editor into it from it's own file so I wont have to store same code in every file. Checking constantly would make that unread count change even when you do nothing.

Link to comment
Share on other sites

The synchronous requests are probably the issue. Once you get it working as you want, I would recommend setting that timeout to 10 seconds or more. It's always better to put less load on the browser and the server, especially if you're expecting high traffic. For something like that notification, someone wouldn't know the difference if it told them they had a new message after 10 seconds (worst case) versus 2 or 3 seconds. You could probably even set it to a minute and people still wouldn't notice.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...