0

在这里,我将代码放入其中,我有 ajax 会在数据表中的下拉菜单的单击事件时触发,在我的 ajax 中,我在单击该特定字段类名时编写 tableid,它在 firefox 中工作正常,但在 google chrome 中不起作用。我使用了 1.7.min.js,当我更改它时,我将它用于所有页面,整个代码将崩溃,所以我无法更改 js。我的代码是 ajax

<script type="text/javascript">

function action()
{
    jQuery('#dyntable').on('click','.quickview',(function()
    {
        //show all hidden row and remove all showed data
        jQuery(this).parents('table').find('tr').each(function()
        {
            jQuery(this).removeClass('hiderow');
            if(jQuery(this).hasClass('togglerow'))
                jQuery(this).remove();
       });

        var parentRow = jQuery(this).parents('tr');
        var numcols = parentRow.find('td').length + 1;          //get the number of columns in a table. Added 1 for new row to be inserted



        //this will insert a new row next to this element's row parent
        parentRow.after('<tr class="togglerow"><td colspan="'+numcols+'"><div class="toggledata"></div></td></tr>');

        var toggleData = parentRow.next().find('.toggledata');

        parentRow.next().hide();

        var qty =  jQuery(this).val();

        jQuery.ajax({   



              url: "ajax/tabledata.php?id="+jQuery(this).val(),

              success:function(data){
                   toggleData.html(data);
                   parentRow.next().fadeIn();   
                },  
                error: function(jqXHR, textStatus, errorThrown) {
                console.log('Error occured: ' + errorThrown);
            }   
          });

        /*var qty =  jQuery(this).val();            
        var url = "ajax/tabledata.php?id="+qty;

        //get data from server
        jQuery.post(url,function(data){
            toggleData.append(data);                        //inject data read from server
            parentRow.next().fadeIn();                      //show inserted new row
                                                            //hide this row to look like replacing the newly inserted row
        });*/

        return false;
    }));


    //for map view of dropdown

    jQuery('#dyntable').on('click','.showmap',(function()
    {
        //show all hidden row and remove all showed data
        jQuery(this).parents('table').find('tr').each(function()
        {
            jQuery(this).removeClass('hiderow');
            if(jQuery(this).hasClass('togglerow'))
                jQuery(this).remove();
       });

        var parentRow = jQuery(this).parents('tr');
        var numcols = parentRow.find('td').length + 1;          //get the number of columns in a table. Added 1 for new row to be inserted
        var qty =  jQuery(this).val();          
        var url = "Mapdashboard.php?id="+qty;


        //this will insert a new row next to this element's row parent
        parentRow.after('<tr class="togglerow"><td colspan="'+numcols+'"><div class="toggledata"></div></td></tr>');

        var toggleData = parentRow.next().find('.toggledata');

        parentRow.next().hide();

        //get data from server
        jQuery.post(url,function(data){
            toggleData.append(data);                        //inject data read from server
            parentRow.next().fadeIn();                      //show inserted new row
                                                            //hide this row to look like replacing the newly inserted row
        });

        return false;
    })); 


}

</script>
4

1 回答 1

0

从 中删除括号:

 jQuery('#dyntable').on('click','.showmap',(function(){...});

To :

  jQuery('#dyntable').on('click','.showmap',function(){...});
于 2013-11-12T08:55:58.900 回答