-2

我把我的 AJAX 放在这里,它在 Firefox 中运行良好,但在 Google Chrome 中无法运行。我尝试了,但它无法在 Google Chrome 中运行。

<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({   

              async: false,

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


               success:function(data){
                   toggleData.append(data);

                    parentRow.next().fadeIn();  
                }           
          });

        /*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

尝试将 dataType 也添加到 ajax 参数中:

dataType: "html"
于 2013-11-11T11:43:43.523 回答