Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
onreadystatechange
Property
readyState Property
responseText Property
// Create a function that will receive data sent
from the server
ajaxRequest.onreadystatechange = function()
{ if(ajaxRequest.readyState == 4)
{ document.myForm.time.value =
ajaxRequest.responseText;
}
}
Prepared by T.C Jayanidu
1.
2.
<html>
<body>
<script language="javascript
type="text/javascript">
function ajaxFunction()
{
var ajaxRequest; // The variable that makes
Ajax possible!
<?php
echo date("H:i:s");
?>
Database search
<html>
<head>
<script type="text/javascript" src=esoft.js"></script>
</head>
<body>
<form>
Select a course :
<select name=course" onchange="show(this.value)">
<option value="1">BCS</option>
<option value="2">BIT </option>
<option value="3">HND </option>
<option value="4">Web Development</option>
</select>
</form>
<br />
<div id=Details"><b>Details for every course will display below</b></div>
</body>
</html>
var xmlhttp;
function show(str)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url=course.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById(" Details
").innerHTML=xmlhttp.responseText;
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
Prepared by T.C Jayanidu
<?php
$course=$_GET["q"];
$con = mysql_connect('localhost', root', root');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db(Esoft", $con);
$sql="SELECT * course WHERE id = ". $course."'";
$result = mysql_query($sql);
echo "<table border='1'>
<tr>
<th>Course</th>
<th>Std Name</th>
<th>Contact Number</th>
<th>Address</th>
<th>status</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row[course'] . "</td>";
echo "<td>" . $row[StdName'] . "</td>";
echo "<td>" . $row[ContactNumber'] . "</td>";
echo "<td>" . $row[Adress'] . "</td>";
echo "<td>" . $row[Status'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>