I am new to using ajax and I want to implement a .post method with an if condition to notify the user of its success or failure.
Here is my code for .post:
$.post("ajaxRegistering.php",{
name: name,
lastname: lastname,
secondlastname: secondlastname,
usernameone: usernameone,
email: email,
passwordone: passwordone,
studentnumberone: studentnumberone,
temp: temp
},
function(data, status){
// alert("Data: " + name + "\nStatus: " + status) ;
sweetAlert("Success", "your account has been created.", "success") ;
}) ;
The above ajax code works fine but I am struggling with adding a failure case. Here is what I have tried:
$.ajax ({
type: "POST",
url: "website.php",
data: data,
success: function(dataone){
sweetAlert("Success", "you have successfully enrolled in momentoSagrado.", "success") ;
}
}) ;
Can someone assist me with this? I believe it may be a simple mistake that I am making.