Jump to content

Help with AJAX / PHP chat


Bigg

Recommended Posts

You would need to store the messages somewhere (either text file or database) so the other users can get the data. Also, you might wanna use the encodeURI() function when creating the URL for your ajax.

I also think you might want to make your http variable global so you can use it in other functions other than the ajaxfunction.

I am making one right now actually, it is almost functional.

 

Client side is all custom JavaScript that I have written (including all the AJAX code) and the backend is run by PHP and MySQL. The Theory is this (I say theory because it isn't complete yet, but close): User logs in (AJAX authentication with the database) then automatically joins the Default channel (which is another AJAX and db call). After that when they send messages an AJAX call is made and adds that message to the database for the specific room they are in. Every second an javascript function is fired off that checks the status (and grabs new messages) of the rooms you are currently in with an AJAX call. This function returns an XML file which is then parsed by my JavaScript (this is what I am having issues with at the moment) and updates the display.

 

I don't know if that is helpful at all, but hopefully it is ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.