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>
From stackoverflow
-
It should be
click
notClick
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.
Efe : 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, defaultGreg : Try making the click function return falseEfe : 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?Greg : No, don't remove the actionEfe : 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/ -
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
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.