Hey!
So, I decided to get off my butt and play with AJAX. I was pleasantly surprised, it really didn't look that hard, so I went ahead and began to play with a VERY simple function:
Code:
<script language="javascript" type="text/javascript">
request = new XMLHttpRequest();
function grabEcho() {
var url = "./echo.php";
request.open("GET", url, true);
request.onreadystatechange = updatePage;
request.send(null);
}
function updatePage() {
if (request.readyState == 4)
document.getElementById("test").value == xmlHttp.responseText;
}
</script>
<form action="POST">
<input type="text" name="test" id="test" onChange="grabEcho();"><br />
<input type="text" name="another" id="another">
</form>
Trouble is... It didn't work!
I know that way of declaring XMLHttpRequest() won't work for all browsers, I'm using Firefox at the moment, just to play, and from what I've read it should work.
echo.php just echoes 'lol', so theoretically, when I go to enter something in the test field, and click off it, it's contents should be replaced with 'lol'. Unfortunately, this isn't happening. What have I screwed up?
Thanks in advance!
|