Encountering an error from the alert in the error function, with additional console.logs for debugging purposes. (Specifically tracking it entering into the error function)
$( document ).ready(function() {
console.log( "ready!" );
$('#register').click(function(){
$.ajax({
url: "./php/register.php",
type: 'POST',
dataType: 'json',
data: {
uname: $('#uname').val(),
usur: $('#usur').val(),
umail: $('#umail').val(),
psw: $('#psw').val(),
conf_psw: $('#conf_psw').val()
},
success:function(data){
switch(data){
case "-1":
$('#content').load("./register.html");
break;
case "0":
$('#content').load("./register.html");
break;
case "1":
$('#content').load("./login.html");
break;
}
console.log("0");
alert(data);
},
error:function(data){
console.log("-1");
alert(data);
}
});
});
});
After following suggestions, encountered this message:
from the alert:
{"readyState":0,"status":0,"statusText":"error"}
Received this response from the echo output:
{readyState: 0, getResponseHeader: ƒ, getAllResponseHeaders: ƒ, setRequestHeader: ƒ, overrideMimeType: ƒ, …}
Further Investigation:
Database entries appear to be successful, possibly triggering the error function due to:
https://stackoverflow.com/questions/44515506/ajax-why-do-i-get-an-error-function-instead-of-success
Alternative Trial:
Tested on a different browser for consistency, here is the result from Microsoft Edge:
Microsoft Edge feedback: