i have this structure in my html
<div id ="slide1">
<form method="post" id="customForm" action="">
//my content - name, email, mypassword, pass2
</form> //i already tried delete this
</div>
<div id ="slide2">
<form method="post" id="customForm1" action=""> //and this, to have only one form obviously this didn't work, because the div of slide1 is already closed.
//my content - other stuff
</form>
</div>
and i have this JS
$(document).ready(function() {
$("#customForm").submit(function() {
$.ajax({
url: "validation1.php",
type: "post",
dataType: "json",
data: {
name: $('#name').val(),
email: $('#email').val(),
myPassword: $('#myPassword').val(),
开发者_开发技巧 pass2: $('#pass2').val()
},
success: function(data) {
//stuff
}
the problem is. I want to group the data of tho slides and send to validation1.php, but for that i must have a only form.
If the problem is not clear please tell me.
thanks
If I understand correctly you are saying that you need to send the 2 slides in one post but in your html the data lives in 2 forms elements.
You can always build a new form with the data you want in it and just submit that, but also review the use of forms on your page anyway.
var href = '.... where ever you are sending the data .....';
var form = $('<form method="post" action="' + href + '"></form>');
var d1=$('.slide1 some subdata selector');
var d2=$('.slide2 some subdata selector')
$('<input type="hidden" name="data1">').val(d1).appendTo(form);
$('<input type="hidden" name="data2">').val(d2).appendTo(form);
$('body').append(form);
form.submit();
form.detach();
精彩评论