chatroom.php******
Web chat room (
being and
chatting)
getmessagecontroller.php********
GetMessage ($getter, $sender); echo $messageList;? >*********messageservice.class.php********
EXECUTE_DML ($sql);} function GetMessage ($getter, $sender) {$sql = "SELECT * from messages where getter= ' $getter ' and sender= ' $sender ' and IsG Et=0 "; $sqlHelper =new sqlHelper (); $array = $sqlHelper->execute_dql2 ($sql); $messageInfo = "
"; for ($i =0; $i
close_connect (); return $messageInfo; }}?>
The great God help to see where the problem is?
Reply to discussion (solution)
Didn't look carefully. Single sentence: Session_Start ();
Because there is an HTML tag in front of the output, there will definitely be "headers already sent" error, right?
You didn't tell me what was wrong with you.
Didn't look carefully. Single sentence: Session_Start ();
Because there is an HTML tag in front of the output, there will definitely be "headers already sent" error, right?
You didn't tell me what was wrong with you.
function GetMessage () {//Create a XMLHttpRequest object var myxmlhttprequest=getxmlhttpobject (); if (myxmlhttprequest) {var url= "getmessagecontroller.php"; var data= "getter=
&sender=
"; Myxmlhttprequest.open ("Post", url,true); Myxmlhttprequest.setrequestheader ("Content-type", "application/x-www-form-urlencoded"); Myxmlhttprequest.onreadystatechange=function () {if (myxmlhttprequest.readystate==4) {if (myxmlhttprequest.status ==200) {//NOTE 1 window.alert ("AAA"); var mesres=myxmlhttprequest.responsexml; var cons=mesres.getelementsbytagname ("Con"); var sendtimes=mesres.getelementsbytagname ("Sendtime"); Note 2 Window.alert ("BBB"); if (cons.length!=0) {for (Var i=0;i
The main problem is the callback function, the response at note 1, but the Window.alert at note 2 will not be able to respond. The great God help to see.
It's important to write robust code.
.... if (myxmlhttprequest.status==200) { var mesres=myxmlhttprequest.responsexml; if (Mesres.xml = = ") {//If it is not an XML object alert (myxmlhttprequest.responsetext);//See what return is returned ; } ....
This estimate is also a appearance bar, the performance is relatively poor.
Chat rooms, using websockeet or comet,
Second, you don't have to use a database, Redis or file storage to
It's important to write robust code.
.... if (myxmlhttprequest.status==200) { var mesres=myxmlhttprequest.responsexml; if (Mesres.xml = = ") {//If it is not an XML object alert (myxmlhttprequest.responsetext);//See what return is returned ; } ....
Thank you, has been solved, blame me careless, originally is MessageService.class.php, the second header () semicolon written a colon, dizzy dead ah!
This estimate is also a appearance bar, the performance is relatively poor.
Chat rooms, using websockeet or comet,
Second, you don't have to use a database, Redis or file storage to
Well, thank you.
Header ("Cache-control:no-cache"):
This kind of mistake, the hint should be obvious.
Thank you, has been solved, blame me careless, originally is MessageService.class.php, the second header () semicolon written a colon, dizzy dead ah!
My mistake is the same as yours, but MessageService.class.php didn't use the header ()??