I'm getting an error returned by the alert in the error:function, notice that I also have different console.logs to know where it's going. (In this case it's going 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);
}
});
});
/*
-1: PASSWORD NÃO COINCIDE COM A SUA CONFIRMAÇÃO
0: EMAIL JÁ EXISTE NA BASE DE DADOS
1: CONTA CRIADA COM SUCESSO
*/
});
I got this after doing what you guys said
from the alert:
{"readyState":0,"status":0,"statusText":"error"}
from the echo:
{readyState: 0, getResponseHeader: ƒ, getAllResponseHeaders: ƒ, setRequestHeader: ƒ, overrideMimeType: ƒ, …}
Second Edit:
I checked the database and it seems its registering the values alright, I guess the error:function is called because of this:
https://stackoverflow.com/questions/44515506/ajax-why-do-i-get-an-error-function-instead-of-success
Third Edit:
So I tried in another browser to see if I'd get the same response, this was the response from Microsoft Edge:
Microsoft Edge feedback:

echothe return in the php and see what is returningconsole.log(data)?