   [web] AJAX Chat help
  Hey,I've been trying to make a ajax chat and got it setup but it wont POST the message when a user sends the message. Its very frustrating cos it sends the UserID but not the message.I create the form where the user puts their message here:// create message input boxfunction createMessageBox(){// create message box containervar mdiv=document.createElement('div');mdiv.setAttribute('id','messagebox');// create message formvar mform=document.createElement('form');// create message boxvar mbox=document.createElement('input');mbox.setAttribute('type','text');mbox.setAttribute('name','message');mbox.className='msgfield';// create 'send' buttonvar mbutton=document.createElement('input');mbutton.setAttribute('type','button');mbutton.setAttribute('value','Send');mbutton.onclick=sendMessage;// create login textvar sp=document.createElement('span');// append elementsmform.appendChild(mbox);mform.appendChild(mbutton);mform.appendChild(sp);mdiv.appendChild(mform);document.getElementsByTagName('body')[[[0]]].appendChild(mdiv);mbox.focus();mbox.onfocus=function(){this.value='';}}Once the form is created the user then submits and this part of the JS i believe excutes:// send user messagefunction sendMessage(){var user='[[2]]';var message=document.getElementsByTagName('form')[[[0]]].elements[[[0]]].value;if(message.length>[[500]]){message=message.substring([[0]],[[500]])};// open socket connectionsenderXMLHttpObj.open('POST','/ajaxchat/sendchatdata.php',true);// set form http headersenderXMLHttpObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');senderXMLHttpObj.send('user='+user+'&message='+message);senderXMLHttpObj.onreadystatechange=senderStatusChecker;}I should note - i did not make this script. Im editing it, it was open source. So i submit a message to a PHP script which recieves the "user" but not the "message" i tested this by doing:<?php$user = SQLskip($_POST['user']);$message = SQLskip($_POST['message']);Echo $user.'<br>';Echo $message;?>$message was undefined, and $user was set correctly. So something is wrong. Hope you can help, if needs be i can send you the real script to edit if this will make life easier to see where the problem lies.   
  Spaces in your message are causing the error, most likely.  Post variables need to be URI encoded.  For example:senderXMLHttpObj.send('user='+encodeURIComponent(user)+    '&message='+encodeURIComponent(message));