I am pretty confused as to how AJAX can send and receive data from a server. So I was wondering if somebody could explain it? Let's say that I already have an XMLHttpRequest set, called "ajax". How could I access a database using that and pull out some data?
Javascript can only send requests to the server and receive a response, but you need a server side script that accesses the database and handles the request. (This can be done with PHP/ASP/etc) Here's a quite simple tutorial. http://www.w3schools.com/ajax/default.asp
Well yeah I know that I need some type of server-side scripting, and I am using PHP to do that. I just don't know how I can get the data using the "responsetext" method, unless I echo all of the data from the server to the file, which seems messy. I'm looking over that tutorial now, though.
No, AJAX get data from your server and assign to a DIV which available on your page. Some methods get data through AJAX - http://javascriptbank.com/javascript/ajax-javascript.html