为什么bootstrap没有调用活动类?

时间:2017-01-04 13:05:33

标签: javascript php jquery ajax twitter-bootstrap

我通过jQuery Ajax从PHP文件接收信息并循环信息,如下所示。我需要它来调用<tr class="active">并将它们放入bootstrap提供的<tr><td>格式。但不幸的是,这种情况并没有发生。

有人有什么建议吗?谢谢:)

function getStudentList() {
     $.ajax({    //create an ajax request to load_page.php
       type: "GET",
       url: "getView.php",             
       dataType: "json",   //expect html to be returned                
       success: function(response){                    
          $.each(response, function(index, response){

          $( "#aaa" ).append('<tr class="active"><td>' + response['Student_ID'] + '</td><td>' + response['FirstName'] + "</td><td>" + response['LastName'] + "</td><td>" + response['Student_ID'] + "</td><td>" + response['Year'] + '</td></tr>');
        });

    },
     error: function(e) {
        //called when there is an error
        console.log("Error: " + e.message);
        }
    });
}

---------- HEADER.PHP ---------------

  <!-- Database Config Files -->
<?php include('db_config.php'); ?>

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">


<!-- Custom css -->
<link rel="stylesheet" type="text/css" href="style.css">

<!-- Latest compiled and minified JavaScript -->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

<script type="text/javascript" src="export.js"></script>
<script type="text/javascript" src="contact.js"></script>
<script type="text/javascript" src="view.js"></script>
<script type="text/javascript" src="create.js"></script>
<script type="text/javascript" src="edit.js"></script>
<script type="text/javascript" src="delete.js"></script>
<script type="text/javascript" src="search.js"></script>

1 个答案:

答案 0 :(得分:1)

我建议你开始使用更好的IDE;我推荐PHPStorm。问题似乎是你的引号的语法。检查这些区域:

你有:

<td>' + response['Student_ID'] + '</td>

应该是:

<td>' + response["Student_ID"] + '</td>

更好的是:

<td>' + response.Student_ID + '</td>