This simple code and I needs your help..
I click this button(editsubmit) and it goes to another page called trailnew.php.. I want to check if the result is success or not... 

I put this in trailnew.php

```
    <?php
    $e=isset($_POST['editsubmit']) && $_POST['editsubmit'];
    if($e)
    {
        echo "inserted";
    }
    ?>

```

And the script..

```
<script>
    $("#editsubmit").click(function(event) {
        event.preventDefault();
        $("#form2").submit()
    });

    $("#form2").validate({
        debug: false,
        rules: {
            plnoedit:"required",
            pldtedit:"required",
            noboxedit:"required",
            glidedit:"required",
        },
        messages: {
            plnoedit: "Please select a pack list id..",
            pldtedit: "Please select a item id id..",
            noboxedit: "Please select a quantity id..",
            glidedit: "Please select a value id..",
        },

        submitHandler: function(form) {
            $.ajax({
                type: "POST",
                url: "trailnew.php",
                data: $('#form2').serialize(),
                cache: false,
                success: function(data) {
                    alert(data);
                }
            });

            return false;
        }
      });
</script>

```

The first page(trailnew.php)

```
<html>
<head>

  <script src="http://code.jquery.com/jquery-latest.js"></script>

 <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.js"></script>
 <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
 <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.js"></script>
 <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.min.js"></script>

 <script>

  $(document).ready(function(){

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

    plid:"required",
       },
   messages: {

    plid: "Please select a pack name id..",
    },

    submitHandler: function(form) {

    $.ajax
   ({

type: "POST",
url: "aanew.php",
data: $('#form1').serialize(),
cache: false,

success: function(response) {
    $('#result1').html(response); 

        }
        });
        }

  });

  </script>

</head>
<body>
<div class="result3"></div>
Packing List
</br>
<form id="form1" name="form1" action="" method="post">
<?php   

echo '<select  name="plid" id="plid">';
echo '<option value="" selected="selected">--Select the Pack Name--</option>';
$tempholder = array();
$sql="SELECT CONCAT( p.pl_no,  '_', DATE_FORMAT( p.pl_dt,  '%d/%m/%Y' ) ,  '_', g.acname ) AS plname, g.gl_id,p.pl_no,p.pl_dt,p.no_box,p.pl_id,g.acname FROM packlist p, glmast g WHERE g.gl_id = p.gl_id ORDER BY pl_dt DESC , pl_no DESC LIMIT 30";

$query = mysql_query($sql) or die(mysql_error());
$nr = mysql_num_rows($query);
for ($i=0; $i<$nr; $i++){
$r = mysql_fetch_array($query);
if (!in_array($r['plname'], $tempholder)){
$tempholder[$i] = $r['plname'];
echo "<option value='$r[pl_id]'>".$r["plname"]."</option>";
}
}

echo '</select>';

?><br/>

<input type="submit" name="delete" id="delete" value="Delete"/><br/>
<input type="submit" name="edit" id="edit" value="Edit"/><br/>
</form>

<form>
<input type="button" name="new" id="new" class="new" value="New" /><br/>
</form>

<?php
$e=isset($_POST['editsubmit']) && $_POST['editsubmit'];
if($e)
{
echo "inserted!";
}
?>

<div id="result1"></div>  

</body>

</html>

```

The second page(aanew.php)

```
<?php
session_start();
include('connect.php');
?>
<html>
<head>

<script src="http://code.jquery.com/jquery-latest.js"></script>

 <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.js"></script>
 <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
 <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.js"></script>
 <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.min.js"></script>
<script>
$("#editsubmit").click(function(event) {
    event.preventDefault();
     $("#form2").submit()
});
 $("#form2").validate({
         debug: false,
   rules: {

    plnoedit:"required",
    pldtedit:"required",
    noboxedit:"required",
    glidedit:"required",

       },
   messages: {

    plnoedit: "Please select a pack list id..",
    pldtedit: "Please select a item id id..",
    noboxedit: "Please select a quantity id..",
    glidedit: "Please select a value id..",

        },

         submitHandler: function(form) {

    $.ajax
   ({

type: "POST",
url: "trailnew.php",
data: $('#form2').serialize(),
cache: false,
success: function(data)
        {
            window.alert(data);
        }

        });
        return false;
        }

  });

</script>
<script>

 $("#form3").validate({
         debug: false,
   rules: {

    plnodelete:"required",
    pldtdelete:"required",
    noboxdelete:"required",
    gliddelete:"required",

       },
   messages: {

    plnodelete: "Please select a pack list id..",
    pldtdelete: "Please select a item id id..",
    noboxdelete: "Please select a quantity id..",
    gliddelete: "Please select a value id..",

        },

         submitHandler: function(form) {

    $.ajax
   ({

type: "POST",
url: "trailnew.php",
data: $('#form3').serialize(),
cache: false,
success: function() {
    alert('Deleted!'); 

        }

        });
        return false;
        }

  });

</script>
</head>

        <body>
        <div id="#result1"></div>
        <?php

    $e=isset($_POST['plid']) && $_POST['plid'];
    $f=isset($_POST['edit']) && $_POST['edit'];
    if($e&&$f)
    {

    $id=$_POST['plid'];
    $query5=mysql_query("SELECT g.gl_id, p.pl_no, p.pl_dt, p.no_box, p.pl_id,g.acname
        FROM packlist p, glmast g
        WHERE g.gl_id = p.gl_id
        AND p.pl_id ='".$id."'
        LIMIT 0 , 30") or die(mysql_error());

    $row=mysql_fetch_array($query5);
    $pl_no=$row['pl_no'];
    $pl_dt=$row['pl_dt'];
    $no_box=$row['no_box'];
    $acname=$row['acname'];

    ?>
        <form name="form2" id="form2" method="post" action="">
        <P>
            <LABEL for="plnoedit">PackList No 
                      <INPUT type="text" id="plnoedit" name="plnoedit" value= <?php echo $pl_no; ?> /></LABEL><BR><BR>
                      <input type="hidden" name="myFormsName" value="form5id" id="myFormsName">
                      <input type="hidden" name="pdidedit" value=<?php echo $id; ?> id="pdidedit">
            <LABEL for="pldtedit">Date 
                      <INPUT type="text" id="pldtedit" name="pldtedit" value= <?php echo $pl_dt; ?> /></LABEL><BR><BR>

            <LABEL for="noboxedit">Box No
                      <INPUT type="text" id="noboxedit" name="noboxedit" value= <?php echo $no_box; ?> /></LABEL><BR><BR>
            <LABEL for="glidedit">Party Name
                      <INPUT type="text" id="glidedit" name="glidedit" value= <?php echo $acname; ?> /></LABEL><BR><BR>

            <INPUT type="button" id="editsubmit" name="editsubmit" value="Submit"> <INPUT type="reset">
            </P> 

        </form>
        <?php

              }

             ?>

        </body>
        </html>

```

The code goes to the trainnew.php I guess, But the alert has all the html loaded into it(The entire new fresh trainnew.php page).. Any suggestions,please?

From Trainnew.php

I use a Edit submit button to get a form from aanew.php(by ajax)

Now I validate this new form in trailnew.php(with validation code in trailnew.php)

Now the problem is that the success ajax call from this form on submit handler, gives me 

the entire new page of trailnew.php..What is that I am doing wrong??

I am trying to figure this from yesterday.... I missing something important here I guess.. Or ajax parts.. Any help highly appreciated!! Thanks a lot in advance..