0

所以我开始使用带有ajax的jquery ..一切都很好..表单已提交..但在响应后表单消失了,只有输出在屏幕上..我试过了

success: function(html)
     {
    $(".result").html(html);
      }

我使用了显示选项,但我的表格没有回来..

$('#myform').show()

我必须做什么,以显示当前的 div 和额外的 div(在 ajax 成功之后).. 希望对此很清楚.. 任何帮助表示赞赏......非常感谢 SO 的所有成员帮助像我这样的可怜的新手..提前谢谢..我的代码我的脚本

$(document).ready(function(){
  $("#form1").validate({
         debug: false,
   rules: {

    passwordid:"required",
    username:"required",
    password_again :"required",
    password_again:{
      equalTo: "#passwordid"
    },
     email: {
     required: true,
     email: true
    }
   },
   messages: {

    email: "Please enter your valid email address.",
    username: "Please enter your username",
    passwordid:"Enter Password",
    password_again:"Please enter the same value",
   },
   submitHandler: function(form) {

    $.ajax
({
type: "POST",
url: "new.php",
data: $('#form1').serialize(),
cache: false,
success: function(html)
{
$(".result").html(html);



 }
            });
        }
    });
});

我的长表格:

//my result class
<div class="result"><div>
<div id="wrapper">


<form name="form1" id="form1" action="" method="post">
<b> Create New Account </b><br><br><br>

<label for="username" id="username_label">Username</label><br>
<input id="username" type="text" name="username"/><br>

<label for="passwordid" id="password_label">Password</label><br>
<br>    <input   type="password" name="passwordid" id="passwordid" size="35">
<br><br>
<label for="password_again" id="password_again_label">Re-Type Password</label><br>
<br><input   type="password" name="password_again" id="password_again" size="35">
<br>
<b>Personal Details</b><br><br>

<label class="r" for="firstname" id="firstname_label">First Name<br>
<input   type="text" name="firstname" id="firstname" size="35"></label><br><br>

<label class="r" for="lastname" id="lastname_label">Last Name<br>
<input   type="text" name="lastname" id="lastname" size="35"></label><br><br>

Gender<br><br>
<select class="cc" name="sex" id="sex">
<option value="" selected="selected">--Select Gender--</option>
<option value="m">Male</option>
<option value="f">Female</option>
</select>

<br><br>
Date of birth<br>

<label class="dob" for="dateid" id="date_label">Date
<?php $number = range(1,31);
$tempholder = range(1,31);
$nr=31;
echo '<select class="doba" name="dateid" id="dateid">';
echo '<option value="" selected="selected">--Select Date--</option>';
for ($i=0; $i<$nr; $i++)
{

        echo "<option>".$tempholder[$i]."</option>";
        }
    echo '</select>';

?>
</label>


<label class="dob" for="month" id="month_label">Month
<?php $number = range(1,12);
$tempholder = range(1,12);
$nr=12;
echo '<select class="doba" name="month" id="month">';
echo '<option value="" selected="selected">--Select Month--</option>';
for ($i=0; $i<$nr; $i++)
{

        echo "<option>".$tempholder[$i]."</option>";
        }
    echo '</select>';

?>
</label>

<label class="dob" for="year" id="year_label">Year
<?php 
$tempholder =  range(1960,2000);
$nr=40;
echo '  <select  class="doba" name="year" id="year">';
echo '<option value="" selected="selected">--Select Year--</option>';
for ($i=0; $i<$nr; $i++)
{
        echo "<option>".$tempholder[$i]."</option>";
        }
    echo '</select>';

?>
</label>
<br><br><br><br>
<b>Contact Details</b> <br><br>
<label for="add1" id="add1_label">Address1</label><br>
<input id="add1" type="text" name="add1"/><br>

<label for="add2" id="add2_label">Address2</label><br>
<input id="add2" type="text" name="add2"/><br>

<label for="add3" id="add3_label">Address3</label><br>
<input id="add3" type="text" name="add3"/><br>

<label for="mobile" id="mobile_label">Mobile</label><br>
<input id="mobile" type="text" name="mobile"/><br>

<label for="tele" id="tele_label">Telephone</label><br>
<input id="tele" type="text" name="tele"/><br>

<label for="email" id="email_label">E-mail</label><br>
<input id="email" type="text" name="email"/><br>

<br>


<b>Card Details</b><br><br>
<label for="cardno" id="cardno_label">Card No</label><br>
<input id="cardno" type="text" name="cardno"/><br>

<label for="cvcno" id="cvcno_label">CVC No</label><br>
<input id="cvcno" type="text" name="cvcno"/><br>




<br>
<select  name="cardtype" id="cardtype">
<option value="" selected="selected">--Card Type--</option>
<option value="visa">Visa</option>
<option value="master">Master</option>
<option value="american">American Express</option>
</select><br><br>

Expiry Date<br><br>

<label class="dob" for="dateid1" id="date_label">Date
<?php $number = range(1,31);
$tempholder = range(1,31);
$nr=31;
echo '<select class="doba" name="dateid1" id="dateid1">';
echo '<option value="" selected="selected">--Select Date--</option>';
for ($i=0; $i<$nr; $i++)
{

        echo "<option>".$tempholder[$i]."</option>";
        }
    echo '</select>';

?>

</label>


<label class="dob" for="month1" id="month_label">Month
<?php $number = range(1,12);
$tempholder = range(1,12);
$nr=12;
echo '<select class="doba" name="month1" id="month1">';
echo '<option value="" selected="selected">--Select Month--</option>';
for ($i=0; $i<$nr; $i++)
{

        echo "<option>".$tempholder[$i]."</option>";
        }
    echo '</select>';

?>
</label>

<label class="dob" for="year1" id="year_label">Year
<?php 
$tempholder =  range(2013,2053);
$nr=40;
echo '  <select  class="doba" name="year1" id="year1">';
echo '<option value="" selected="selected">--Select Year--</option>';
for ($i=0; $i<$nr; $i++)
{
        echo "<option>".$tempholder[$i]."</option>";
        }
    echo '</select>';

?>
</label>
<br><br>
<input type="submit" class="ss" value="SUBMIT" class="left" >


</form>
4

1 回答 1

1

只是和想法,但你可以尝试

    $(".result").append(html);

反而。.html 可能会以某种方式清除您的 html。

于 2013-04-02T13:32:53.877 回答