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.

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.