Hi!
I am trying to make a simple test AJAX script...

loadFile.html:
Code:
<script>
function performRequest()
{
	var req = new XMLHttpRequest();
	req.open("POST", "./bounce.php", false);
	req.onload = function()
	{
		alert(req.responseXML);
	};
	req.send(new FormData(document.getElementById("uploadForm")));
}
</script>

<body>
	<form	enctype= 'multipart/form-data' method= 'POST' name= 'uploadForm' id= 'uploadForm' action= ''>
		<input type= 'hidden' name= 'mode' id= 'mode' value= 'upload'>
		<input type= 'file' name= 'sourcefile' id= 'sourcefile' required>
		<input type= 'button' value= 'Upload' onClick= 'performRequest()'>
	</form>
</body>
bounce.php:
PHP Code:
<?php
    
if ($_POST["mode"] == "upload")
        if (
is_uploaded_file($_FILES["sourcefile"]["tmp_name"]))
            @
readfile($_FILES["sourcefile"]["tmp_name"]) or exit("Dang!");
?>
I want it to alert the contents of the selected file when I click "Upload," but for some reason it navigates me to "bounce.php" and displays the content there!
I thought AJAX was supposed to be about not leaving the page...
What am I doing wrong?