I want to retrive information from a database with AJAX/PHP.I don't know how to make the returned from the database information available to the javascript code,there is xmlHTTP.responseText variable,i don't know how to use it.Basically my question is: how to make the information available to to responseText?
JavaScript codeCODE
<script>
function getInformation()
{
var xmlHttp;
try
{
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=changeContent();
xmlHttp.open("GET","bla.php",true);
xmlHttp.Send(null);
}
function changeContent()
{
if (xmlHttp.readyState==4)
{ alert(xmlHttp.responseText);
document.getElementById("div1").innerHTML=xmlHttp.responseText;
}
}
</script>
PHP codeCODE
<?php
$connection = mysql_connect('localhost','root','');
if(!mysql_select_db('products'))
{
exit(mysql_error());
}
$result = mysql_query('SELECT * FROM boots',$connection) or die(mysql_error());
while($products = mysql_fetch_array($result))
{
}
mysql_close($connection);
?>