1

Yo.

I'm really quite new to this whole JavaScript business, not to mention AJAX, so I was thinking if you guys could help me out with a conundrum.

Basically, what I want is for the user to be notified upon a change in a value of a MySQL table. How should I go about that? Should I use jQuery, or can I slap something together myself?

Thankful for any and all replies.

4 Answers 4

3

Depending on how quickly you need the users to be notified, you could use either polling (sending a request every X seconds to see if there's anything new) or use comet.

In any case, you'll need a server side programming language to be querying the database and serving the results, and you'll need some javascript on the client-side to be sending requests and displaying responses. I would highly recommend using the jQuery library, since it simplifies a lot of cross-browser incompatibility.

Sign up to request clarification or add additional context in comments.

Comments

1

Well, this is a bit abstract, but there are two parts to this: a server-side script, and your AJAX code (which sends this request to the script). Your server-side script will actually be doing the query to see if the database has changed, so your JavaScript will have to have a periodic execution (say once every ten seconds or whatever interval is right for you) if you are not waiting for the user to refresh their page.

The chain of events will look something like this:

AJAX -> Script -> DB -> Script -> AJAX -> Update Web Page

You will definitely want to use jQuery, Prototype, or some similar framework if you are new to AJAX. It will save you tons of time.

Comments

0

You should use jQuery and jQuery ajax method http://api.jquery.com/jQuery.ajax/

Comments

0

In the HTML page, the JavaScript will use AJAX to keep requesting a backend page during a certain interval. The backend page will check if a MySQL database was changed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.