forum

Home / DeveloperSection / Forums / How to posting data from Jquery Form

How to posting data from Jquery Form

Anonymous User 2043 05-Feb-2015

I have a simple jquery form which gets the input from user and posts the data to another page and displays a success message. But my problem is the data doesn't get posted to the other page, instead the error message gets popped up.

Here is my Jquery:

 $(document).ready(function () {
     $("#register").click(function () {
    var name = $("#name").val();
    var email = $("#email").val();
    var password = $("#password").val();
    var cpassword = $("#cpassword").val();
    if (name == '' || 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",  //trying to post to this url
            data: { firstName: name },
 
            success: function (msg) {
                alert("Success");   // Success message which should pop up if successful
            },
            error: alert("Failed")   //error message which should pop up if there is an error
        });
    }
});
});

Here is the code in signup.aspx page (code behind class):

         public string register(String firstName)
         {
            return "Success";           
         }

The url i have provided is correct there is no problem with that. What might be the problem here ?

Also are there another methods to send data to another page?

Thank you for your time


Updated on 05-Feb-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By