I have "create user" form which has to check if the username already exists. For that, I made an onclick function on a button starting this script:
$.ajax({
type: \"POST\",
dataType: \"json\",
url: \"test.php\",
data: $('input[name=Username]').val(),
contentType: \"application/json; charset=utf-8\",
success: function(data){
alert('Items added');
},
error: function(e){
console.log(e.message);
}
});
However, nothing happens, even not the alert stating succes! Please help me out how to post that single variable and how to get the result from the PHP page checking the existance of the username.
\"come from?contentTypeis theContent-Typebeing sent to the server in the request. Remove that, you are not sending JSON.