I have a jquery form which sends data to a code behind class to store that data in a local db. When the method successfully stores the data , the method returns a message which should be shown to the user through the jquery and it should then automatically re-direct the user to the login page.
I have managed to store the data to the local db which i get through the jquery form , but i have no idea of implementing the part to show the message to the user which gets returned from the method and how to redirect the user to the login page.
Here is my Jquery code
$(document).ready(function () {
$("#register").click(function () {
var userName=$('#userName').val();
var firstName=$("#firstName").val();
var lastName=$("#lastName").val();
var email = $("#email").val();
var password= $("#password").val();
var cpassword= $("#cpassword").val();
var country= $("#country").val();
var request=JSON.stringify({
userID: userName,
firstName: firstName,
lastName: lastName,
email: email,
password: password,
country: country,
userType:"Normal"
});
if (userName == '' || email == '' || password == '' || cpassword == '') {
alert("Please fill all fields...!!!!!!");
} else if ((password.length) < 8) {
alert("Password should atleast 8 character in length...!!!!!!");
} else if (!(password).match(cpassword)) {
alert("Your passwords don't match. Try again?");
} else {
$.ajax({
type:"POST",
url: "SignUp.aspx/register",
data: request,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (request) {
alert("Successfully Registered"); //i just display this message since i don't know how to display the returned message from the method
},
error: function (err) { alert("Registration Failed, Please try again Later!") }
});
}
});
});
My code behind class is a normal c# class which returns a message saying successfully registered after storing the data. I haven't posted it here since its just a normal class.