Forum Moderators: coopster
function autoRefresh(){
var myAjax = new Ajax.Request( \'Sources/tpvchat/func/chat.php\', {method: \'post\', parameters: "act=clientIn&guestname='.$_SESSION['chatsession'].'", onComplete: function(res){
ob=JSON(res)
if (ob.error){alert(ob.errors)}
}});
new Ajax.PeriodicalUpdater("content",\'Sources/tpvchat/func/chat.php\' , {asynchronous:true, frequency:1, method: \'post\', parameters: "act=get"});
}
function doRefresh(){
new Ajax.Updater("content",\'Sources/tpvchat/func/chat.php\' , {method: \'post\', parameters: "act=get"});
}
function PostMessage(form) {
var myAjax = new Ajax.Request( \'Sources/tpvchat/func/chat.php\', {method: \'post\', parameters: "act=post&"+Form.serialize(form), onComplete: function(res){
ob=JSON(res)
if (ob.error){alert(ob.errors)}
}});
setTimeout("doRefresh()",1);
el=document.getElementById("Tmessage")
el.focus();
setTimeout(\'el.value=""\',3);
el.value="";
}
function ClearChat(form) {
var myAjax = new Ajax.Request( \'Sources/tpvchat/func/chat.php\', {method: \'post\', parameters: "act=clearchat", onComplete: function(res){
ob=JSON(res)
if (ob.error){alert(ob.errors)}
}});
setTimeout("doRefresh()",1);
}
function delPost(id) {
var myAjax = new Ajax.Request( \'Sources/tpvchat/func/chat.php\', {method: \'post\', parameters: "act=del&id="+id , onComplete: function(res){
ob=JSON(res)
if (ob.error){alert(ob.errors)}
}});
setTimeout("doRefresh()",1);
}
_handleKey=function(ob,e){
e.Key=(e.keyCode)?e.keyCode:e.which;
if (e.Key==13){
if (e.shiftKey){
return true;
}else{
PostMessage(ob.form);
try{
ob.preventDefault();
}catch(e){
ob.returnValue=false;
}
ob.value=""
return false;
}
}
}
function leaveChat(){
var myAjax = new Ajax.Request( \'Sources/tpvchat/func/chat.php\', {asynchronous:false,method: \'post\', parameters: "act=clientOut&guestname='.$_SESSION['chatsession'].'", onComplete: function(res){
ob=JSON(res)
if (ob.error){alert(ob.errors)}
}});
}
</script>';
} The code gives 2 errors...Undefined index: chatsession
Would anyone be so kind as to offer a solution?
At first glance it looks like you are passing chatsession back to chat.php, along with other parameters. One possibility is that you are using a GET in chat.php, but you are POST'ing the values from this script. If that's the problem, the solution is to read your POST variables in chat.php
$x = $_POST['abc'];