gpt4 book ai didi

javascript - 为什么 Bootstrap 不调用事件类?

转载 作者:行者123 更新时间:2023-12-03 05:19:19 24 4
gpt4 key购买 nike

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

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

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>

最佳答案

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

你有:

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

应该是:

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

更好:

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

关于javascript - 为什么 Bootstrap 不调用事件类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41464565/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com