jquery表单提交不在chrome和mozilla中工作

时间:2014-06-05 19:40:15

标签: php jquery html

我想使用php mysql和jquery编辑一个表行。这是我的脚本。我的php文件正在拥有具有编辑按钮的动态表。

<script type="text/javascript">
        $(document).ready(function(){
            function loading_show(){
                $('#loading').html("<img src='images/loading.gif'/>").fadeIn('fast');
            }
            function loading_hide(){
                $('#loading').fadeOut('fast');
            }                
            function loadData(page){
                loading_show();                    
                $.ajax
                ({
                    type: "POST",
                    url: "test2.php",
                    data: "page="+page,
                    success: function(msg)
                    {
                        $("#container1").ajaxComplete(function(event, request, settings)
                        {
                            loading_hide();
                            $("#container1").html(msg);
                        });
                    }
                });
            }
            loadData(1);  // For first time page load default results
            $('#container .pagination li.active').live('click',function(){
                var page = $(this).attr('p');
                loadData(page);

            });           
            $('#go_btn').live('click',function(){
                var page = parseInt($('.goto').val());
                var no_of_pages = parseInt($('.total').attr('a'));
                if(page != 0 && page <= no_of_pages){
                    loadData(page);
                }else{
                    alert('Enter a PAGE between 1 and '+no_of_pages);
                    $('.goto').val("").focus();
                    return false;
                }

            });
            // For edit button
             $('#go_btn1').live('click',function(){
                             var divId = "#edit" +      $(this).attr('class'); 
             $('#edit'+$(this).attr('class')).toggle("slow",function(){

               });

            });
             // For Delete button
              $('#go_btn2').live('click',function(){
                             var divId = "#text" + $(this).attr('class'); 
             $('#del'+$(this).attr('class')).toggle("slow",function(){

               });

            });
            // For close button edit
             $('#lo_btn1').live('click',function(){
                                $('#edit'+$(this).attr('class')).toggle("slow",function(){

               });

            });
             // For close button delete
              $('#lo_btn2').live('click',function(){
                                $('#del'+$(this).attr('class')).toggle("slow",function(){


               });

            });
            $("#do1").live('click',function(){
 alert("Submitted");
 });
$("#do2").live('click',function(){
$("#save").submit();
});


        });
    </script>

`

我的php文件是 -

       $msg = "";
     echo "<table style='border:1px solid black; width:100%; word-wrap:break-word;   table-layout: fixed;'><tr class='table_top'><th width='15'>S.No</th><th width='150'>CircularNumber</th><th width='50'>Date</th><th width='50'>Sect.</th><th width='200'>CirSubject</th><th width='50'>Compliance</br>Required</th><th width='75'>Edit</th><th width='75'>Delete</th></tr>";
$x=0;
     while ($row = mysql_fetch_array($result_pag_data)) {


        $catsno=$row['cirid'];
        $catcirid=$row['cirid'];
        $catcir = $row['cirnumber'];
        $catdate = $row['cirupdate'];
        $catsect = $row['cirsection'];
        $catsub = $row['cirsubject'];
        $catmulti = $row['multiplefiles'];
        $comply=$row['compliancereq'];
        $catremarks=$row['remarks'];
        $upoloaddir='uploads/';

                  $x++; 

   $class = ($x%2 == 0)? 'whitebackground': 'graybackground';

      $msg.='<tr class="'.$class.'" ><td width="15">'.$x.'</td><td width="150 ">'.$catcir.'</td><td width="50">'.$catdate.'</td><td width="50">'.$catsect.'</td>';


        //for edit
        $msg.="<td width='75'><input type='button' id='go_btn1' class='$x'  value='Edit'/></td>";
 echo "<div class='edit' id='edit$x' ><form method='post'  enctype='multipart/form-data'   action='do_circular.php'>
  <input type='hidden' name='Cirid'  value=$catcirid/>
 <input type='text'  name='CirNumber' value='$catcir' />
 <input type='button' id='lo_btn1' class='$x' value='close'/>
 <button type='submit' name='dosave' id='do1' value='Save' /></form></div>";
                $msg.='</tr>';
    }

 $msg = "<div class='data'>" . $msg . "</div></table>"; // Content for Data

上面的表单在ie8中工作,但是在mozila nad firefox中,表单没有提交。

1 个答案:

答案 0 :(得分:1)

您提交的是按钮,而不是表单。 尝试:

$( 'form' ).submit();

你也在使用live(),这是被删除的。最好使用.on()。