Jump to content

[SOLVED] Ajax Chat


GameYin

Recommended Posts

Ugh yes I do. Sorry for wrong thread but I believe the AJAX part isn't wrong.

 

No errors are given. If you would please go to the site (not trying to be rude) and type something in, you will see nothing happens. The data isn't going to the table and thus nothing shows up. (My theory). (Well, I KNOW it isn't going to the table (SELECT *  FROM chat)).

Link to comment
Share on other sites

Not sure but you have a html/css issue, highlighted below

<div id="view_ajax" style="overflow=auto; width: 500px; color:red; height: 300px; border: 1px dotted red;">

CSS attributes are assigned with a colon ( : ) not an equals sign.

 

As for why the message is not being displayed there is most probably a bug in your Javascript. You may want to try FireBug (a Firefox extension) a try to debug your JavaScript.

 

Also do not bump your post ever couple of hours, allow up to 12 hours for a reply. It also helps if you posted your problem in the correct forum, posting in the forum with the "most traffic" will not get your question answered quicker.

Link to comment
Share on other sites

I believed my problem was not with JavaScript/Ajax so I posted this in the PHP help. As it turns out I was right. I'm now trying to make it so you can set your own username. Will post back soon

 

Also I tend to get ancy when I can't figure something out.

Link to comment
Share on other sites

Ok Now I need help with JavaScript. I want users to set their own username.

 

gameyin.com/ajaxchat/

 

type in the 2nd text field waht you want your username to be

 

function setName() {
var username = document.set.Name.value;
username=document.cookie = "name="+ username + ";";
http[username]=createRequestObject();
http[username].open(\'get\', \'submit.php?username=\'+ username);
http[username].send(null);

}

</form>
                        <form name="setMyName" id="set" method="get">
                        <input type="text" id="Name" />
                        <input type="submit" onclick="setName()" />
                        </form>

Link to comment
Share on other sites

In my setName function, I wasn't calling the form...I got part of it owrking. I can get a name to display, but you can't get a message in. Like, if you fill out both fields, ...hard to explain, go there and mess with it. The database is only adding a name OR text depending on which submit button you do.  Should I combine functions??

Link to comment
Share on other sites

You seem to think I'm pro at this stuff xD. I'm only 16...I know a little bit of PHP but AJAX is my worst part.

 

 

Errrr.... I'm only 16 ;p.  Has less to do with age and more to do with how long you've been coding.

 

 

 

Anyway, if you want users to not be able to steal each other's names, you will probably want to log them in via some kind of PHP script, and just use sessions.

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.