I have a division within my main page
I have a JS
My PHP script looks as follows
If I run the PHP script by itself, I do get the drop down list. I have tried not to ask for help (I have to learn this) but after spending all afternoon and this evening looking at it, I think I will never find the problem; no matter how simple it is.
Regards,
Jose
Code:
<div id="chatUserList"></div>
I have a JS
Code:
/**
* @author JPA
*/
var timer = null;
var chatUser;
var xo = null;
var url = 'listChatUser.php';
function createObject(){
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
xo = new ActiveXObject("Microsoft.XMLHTTP");
}else{
xo = new XMLHttpRequest();
}
}
function updateChatUser(){
if (!xo) {createObject();}
xo.onreadystatechange = function () {
if (xo.readyState == 4) {
if (xo.status == 200) {
if(xo.responseText == ''){
//do nothing
} else {
//alert(xo.responseText);
displayUpdatedUsers(xo.responseText);
}
}
}
};
try {
xo.open("POST",url, true);
} catch (e) {
console.log('problem in open command') ;
}
try {
xo.setRequestHeader("Content-type", "application/x-[URL unfurl="true"]www-form-urlencoded");[/URL]
xo.send('action=listusers');
} catch (e) {
console.log('problem retrieving new chats');
}
}
function displayUpdatedUsers(txt){
chatUser.innerHTML = txt;
}
window.onload = function(){
chatUser = document.getElementById('chatUserList');
timer = setInterval(updateChatUser, 5000);
};
My PHP script looks as follows
Code:
<?
$sql = "SELECT * FROM chatuser WHERE userName != '' ORDER BY userLoginTimeStamp DESC";
$dbserver = mysql_connect("localhost","user","password");
mysql_select_db("dbname", $dbserver);
$data = mysql_query($sql);
$return = "<select>";
while ($row = mysql_fetch_assoc($data))
{
$return .= "<option>" . $row['userLogInTimeStamp'] . " " . $row['userName'] . "</option>";
}
$return .= "</select>";
echo $return ;
?>
If I run the PHP script by itself, I do get the drop down list. I have tried not to ask for help (I have to learn this) but after spending all afternoon and this evening looking at it, I think I will never find the problem; no matter how simple it is.
Regards,
Jose