Javascript

Status
Not open for further replies.

dropper

Beta member
Messages
3
Big thing I am working on, help me get started

Well, I want to make a thing with PHP and AJAX/Javascript that updates a TEXTAREA box each time the database is changed.

Whats more, I need the textarea to be able to have colored text inside of it,

or make it somewhat like a textarea appearance, maybe a DIV? It cannot be written inside of.

Can somebody show me a tutorial?
 
I don't know of any specific tutorials, but I'd work on simply understanding the basics of AJAX... w3c's tutorial/intro, for example.

The text area (or any other visible HTML object) appearance can be controlled completely by CSS.

I recently wrote a simple "post" with it, which you can see/use on my website, and with that, if you view the source, you can see everything that goes on.

An excellent utility to have when working with any Javascript is a Firefox plugin, FireBug. It lets you see every javascript request, including the http requests/return values... I couldn't have found some simple bugs without its help. :)

As for updating whenever the database is changed, with my "post", what I have it do is:
1. When the server script is called, it checks the timestamp and if there have been changes, return the last X messages.
2. It returns a "change" value each time (0/1), so I know to update the fields if there has been an update (1), and to save a little bandwidth (by not sending the list of messages each time).

Of course it's just a start, but quite a bit of fun!

If you have any specific questions/issues with it though, do ask!

PS: One issue that took me hours to figure out, when using the javascript xml parser, remember that the server-side script needs to return the content-type of XML. I didn't do that, so the javascript always saw it as a null object.
 
Status
Not open for further replies.
Back
Top Bottom