I find it hard to explain so I'm going to write down my code
test.php
<?php
if ($_GET['value']=="1")
{
$x='It is working fine';
exit();
}
?>
<html lang="en">
<head>
<script type="text/javascript" src="ajax.js"></script>
</head>
<body>
<form method="post" action="">
<select name="s" onchange="makerequest('test.php?value='+ this.value)">
<option value="">Select One</option>
<option value="1">One</option>
</select><br/>
<input type="text" id="res" name="res" value="<?php if (isset($x)) echo $x;?>"/><br/>
<input type="submit" name="submit" value="go" />
</form>
</body>
</html>
// Creating the xmlhttp
function makerequest(serverpage)
{
xmlhttp.open("GET",serverpage);
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
document.getElementById("res").value=xmlhttp.responseText;
}
xmlhttp.send(null);
}
When I try to echo $x, nothing happen although, $x is set in the same script (test.php).
What's wrong with this code?
Thanks for the help