shedokan
11-13-2007, 10:56 PM
here is the script:
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
window.onload=function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
requestNews = ajaxRequest;
requestNews.onreadystatechange = function(){
if(requestNews.readyState == 4){
var newsDisplay = document.getElementById("news");
newsDisplay.innerHTML = requestNews.responseText;
}
}
requestNews.open("GET", "news.php", true);
requestNews.send(null);
}
//-->
</script>
here is the page:
<!-- here is the header style of the page-->
<center>
<div style="border:1px solid black;background-color:#DDDD00;width:95%;padding:2px;" align="right">
.ברוכים הבאים לניאוסטאר, כאן תוכלו למצוא את כל העזרה שאתם צריכים בניאופטס
</div>
<br>
<table cellspacing="5" cellpadding="0" width="95%">
<thead style="background-color:#DDDD00;">
<tr>
<td align="right" style="font-size:15pt;font-weight:bold;font-family:arial;">:חדשות</td>
</tr>
</thead>
<tbody id="news">
</tbody>
</table>
</center>
<!-- here is the footer style of the page-->
here is the php:
<?php
//here includes the config
// how many rows to show per page
$rowsPerPage = 5;
// by default we show first page
$pageNum = 1;
$query = "SELECT * FROM news LIMIT 5";
$result = mysql_query($query) or die('Error:4;');
// print the random numbers
while($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td>';
echo '<table cellspacing="0" align="center" width="100%">';
echo '<tbody align="right" style="background-color:white;">';
echo '<tr>';
echo '<td>';
echo $row['text'];
echo ' </td>';
echo '</tr>';
echo '</tbody>';
echo '<tfoot style="background-color:#DDDD00;">';
echo '<tr>';
echo '<td colspan="5" align="right">'.$row['date'].'</td>';
echo '</tr>';
echo '</tfoot>';
echo '</table>';
echo '</td>';
echo '</tr>';
}
?>
the problem is that it doesn't put the response text in the table body with the id news
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
window.onload=function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
requestNews = ajaxRequest;
requestNews.onreadystatechange = function(){
if(requestNews.readyState == 4){
var newsDisplay = document.getElementById("news");
newsDisplay.innerHTML = requestNews.responseText;
}
}
requestNews.open("GET", "news.php", true);
requestNews.send(null);
}
//-->
</script>
here is the page:
<!-- here is the header style of the page-->
<center>
<div style="border:1px solid black;background-color:#DDDD00;width:95%;padding:2px;" align="right">
.ברוכים הבאים לניאוסטאר, כאן תוכלו למצוא את כל העזרה שאתם צריכים בניאופטס
</div>
<br>
<table cellspacing="5" cellpadding="0" width="95%">
<thead style="background-color:#DDDD00;">
<tr>
<td align="right" style="font-size:15pt;font-weight:bold;font-family:arial;">:חדשות</td>
</tr>
</thead>
<tbody id="news">
</tbody>
</table>
</center>
<!-- here is the footer style of the page-->
here is the php:
<?php
//here includes the config
// how many rows to show per page
$rowsPerPage = 5;
// by default we show first page
$pageNum = 1;
$query = "SELECT * FROM news LIMIT 5";
$result = mysql_query($query) or die('Error:4;');
// print the random numbers
while($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td>';
echo '<table cellspacing="0" align="center" width="100%">';
echo '<tbody align="right" style="background-color:white;">';
echo '<tr>';
echo '<td>';
echo $row['text'];
echo ' </td>';
echo '</tr>';
echo '</tbody>';
echo '<tfoot style="background-color:#DDDD00;">';
echo '<tr>';
echo '<td colspan="5" align="right">'.$row['date'].'</td>';
echo '</tr>';
echo '</tfoot>';
echo '</table>';
echo '</td>';
echo '</tr>';
}
?>
the problem is that it doesn't put the response text in the table body with the id news