tags:

views:

64

answers:

2

Using jquery, I want to post data to from one of my pages to another one. By looking at examples, I coded something. Problem here, I get the following error.

Error: $(document.getElementsByName("signup")).Click is not a function Source File: http://sabahtan.com/ak/ Line: 18

    $(document).ready(function() { 
        $(document.getElementsByName("signup")).Click(function() { 
                $.ajax({
                        type: "POST",
                        data: { PROCESS: "Add2Member", FIRSTNAME: $(document.getElementsByName("FIRSTNAME")).val(), LASTNAME: $(document.getElementsByName("LASTNAME")).val(), EMAILADDRESS: $(document.getElementsByName("EMAILADDRESS")).val(), PASSWORD: $(document.getElementsByName("PASSWORD")).val(), CITY: $(document.getElementsByName("CITY")).val() },
                        url: "default.cs.asp", 
                success: function(output) { 
                $("#SIGNUPFORM").html(output);
                }
                }); 
        }); 
    });


                    <form method="post" action="default.cs.asp?Process=Add2Member" id="SIGNUPFORM">
                        <fieldset>
                            <p>
                                <label>Adınız</label>
                                <input type="text" name="FIRSTNAME" />
                                <small><%=err_FIRSTNAME%></small>
                            </p>
                            <p>
                                <label>Soyadınz</label>
                                <input type="text" name="LASTNAME" />
                                <small><%=err_LASTNAME%></small>                                    
                            </p>
                            <p>
                                <label>E-posta Adresiniz</label>
                                <input type="text" name="EMAILADDRESS" />
                                <small><%=err_EMAILADDRESS%></small>
                            </p>
                            <p>
                                <label>Şifreniz</label>
                                <input type="text" name="PASSWORD" />
                                <small><%=err_PASSWORD%></small>
                            </p>
                            <p>
                                <label>Yaşadığınız Yer</label>
                                <input type="text" name="CITY" />
                                <small><%=err_CITY%></small>
                            </p>
                            <p>
                                <input type="submit" name="signup" value="Kaydol" class="signup">
                            </p>
                        </fieldset>
                    </form>
A: 

It should be click not Click

You can use selectors to simplify this:

$(document.getElementsByName("signup")).Click(function() {

to this:

$("*[name=signup]")).click(function() {

Though personally I'd just put an id on the signup element.

Greg
Thanks! I dont receive the error anymore. But, when submit clicked, user still redirected to default.cs. But I want them stay on the same page, default
Efe
Try making the click function return false
Greg
I have url: "default.cs.asp" in javascript but I did not remove action="default.cs.asp?Process=Add2Member" from the form. Do I need to remove it?
Efe
No, don't remove the action
Greg
hey this still is not working as I want it to be. When submit button click, page still redirected. Text link: http://www.aslanyurek.com/
Efe
A: 

I'm pretty sure you want submit and check out serialize

$("#SIGNUPFORM").submit(function() {
                 $.ajax({
                    type: "POST",
                    data: $(this).serialize() ,
                    url:  this.action, 
            success: function(output) { 
            $("#SIGNUPFORM").html(output);
            }

  return false;
});

If you really want to make life easy you can check out the Form plugin

Andy Gaskell