Okay I moved the username variable but I've been looking online for documentation of response but I can't find anything. Here is what I have so far but it doesn't return anything.
PHP Code:
<?php
if(isset($_POST['username'])) {
sleep( 2 );
echo $_POST['username'];
exit();
}
?>
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Spinner</title>
<!-- load the dojo stylesheet FROM AOL -->
<link rel="stylesheet" type="text/css" href="http://o.aolcdn.com/dojo/1.3.2/dojo/resources/dojo.css" />
<!-- load the DOJO LIBRARY FROM AOL -->
<script type="text/javascript" src="http://o.aolcdn.com/dojo/1.3.2/dojo/dojo.xd.js"></script>
<script type="text/javascript">
//var username = document.getElementById('login_name');
//var username = document.form.login_name.value;
function ajax(){
dojo.xhrPost({
url: 'spinner2.php',
handleAs: 'text',
timeout: 15000,
content: { 'username': username } ,
load: function(response, args){
// THIS OVERWRITES THE SPINNER GIF HTML, IE 'MAKES IT DISAPPEAR'
// YOU DO THIS ON SUCCESS OR FAILURE
dojo.byId("results").innerHTML = response.responseText ;
return response; } ,
error: function(response, args){
dojo.byId("results").innerHTML = "Error: The description is: " + response.description ;
return response; }
} );
}
function checkSubmit(){
var username = dojo.byId("login_name");
// MAKE SURE FORM IS FILLED OUT PROPERLY, ETC
// DISPLAY THE SPINNER -- you do this just before you send the Ajax request
dojo.byId("results").innerHTML = '<div class="centered"><img src="https://podaci.co.uk/design/style/loading.gif"></div>' ;
// SEND THE FORM VIA AJAX
ajax();
return false;
}
</script>
</head>
<body >
<h3>Spinner Demo</h3>
<form action="" method="POST" name="form01" id="form01" onSubmit="return checkSubmit();">
Login Name: <input type="text" name="login_name" id="login_name" />
<br />
<input type='submit' id="submit_button" value="Submit" />
<br />
</form>
<div id="results"></div>
<!-- PRELOAD THE SPINNER GIF -->
<span style="visibility:hidden;" >
<img src="https://podaci.co.uk/design/style/loading.gif" height='16' width='16' >
</span>
</body>
</html>