Нужно, чтобы по щелчку на ссылке в div выводилась таблица, которая берётся из mysql php скриптом. Этот код не работает. Подскажите, что не так?
<html>
<head>
<script type="text/javascript">
function getXmlHttp()
{
var xmlhttp;
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (E)
{
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined')
{
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function loadXMLDoc(method, url)
{
req = getXmlHttp();
req.open(method, url, true);
req.onreadystatechange = processReqChange;
req.send(null);
}
function processReqChange()
{
if(req.readyState == 4)
{
if(req.status == 200)
{
if (req.responseXML != null)
{
gtable = req.responseXML.getElementsbyTagName('table');
getTable(gtable);
}
}
else
{
alert("There was a problem retrieving the XML data:\n" + req.statusText);
}
}
}
function onClick()
{
var url = "wengine/wlist.php";
loadXMLDoc( "get", url );
}
function getTable( database )
{
var database = document.getElementById( "database" );
database.innerHTML = database;
}
</script>
</head>
<body>
<div id="database"></div>
<span style="color:blue; text-decoration:underline; cursor:pointer" onClick="onClick()">ссылка</span>
</body>
</html>
php-скрипт
<?php
header ('Content-Type: text/xml');
echo '<table bgcolor="#ffcc00" cellspacing="4">';
$query='SELECT uid,header,content,summ FROM table1 ORDER by `uid` ';
$result = mysql_query($query);
do
{
echo '<tr>';
$row=mysql_fetch_row($result);
echo '<td width="24" class="c">'.$row[0].'</td><td width="150">'.substr($row[1],0,15).'</td>
<td width="560">'.substr($row[2],0,67).'</td>
<td width="100">'.substr($row[3],0,10).'</td>
';
echo '</tr>';
}
while ($row);
echo '</table>';
?>