The success part of the ajax function is never reached. I've spent hours on it, still no success. The code has been stripped of virtually everything necessary just to try and remove any possible problems but it still doesn't work.
Below is the stripped out code that I'm trying to get to work. Thanks for any help.
Ajax:
function validLogin(){
var url = "loginProcessAjax.php";
$.ajax({
type: 'POST',
url: url,
beforeSend: function() {
//
alert("sdfs");
},
success: function(html) {
alert("success");
alert(html.getElementsByTagName("worked")[0].firstChild.nodeValue);
},
error: function( error ) {
console.log(error);
}
});
}
PHP:
<?php
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='ISO-8859-1'?>";
echo "<worked>";
echo "success";
echo "</worked>";
?>
HTML:
<form method="post" action="" id="ourLoginFormID_JS">
<div class="ourContactFormElement2">
<label for="username">Username:</label>
<input type="text" id="username" name="username" autocomplete="off" class="required" value="<?php if(isset($_POST['username'])) echo htmlentities($_POST['username']); ?>" />
</div>
<div class="ourContactFormElement2">
<label for="password">Password:</label>
<input type="password" id="password" name="password" autocomplete="off" class="required"/>
</div>
<div class="ourContactFormElement2">
<label> </label>
<input type="submit" name="loginButton" id="loginButton" value="Login!" onclick="validLogin()"/>
</div>
<div id="statusLogin"></div>
</form>
In beforeSend, the alert box with xml doesn't get generated. the other one does so I know it's at least calling the function.