gpt4 book ai didi

javascript - Uncaught ReferenceError - 找不到函数

转载 作者:行者123 更新时间:2023-11-28 00:44:34 24 4
gpt4 key购买 nike

我正在开发一个网站来显示数据库中的数据。当我点击一行时,我尝试进行 url 调用。要调用 url,请在单击该行时调用一个函数,但该函数会引发错误。

Uncaught ReferenceError: clickableRow is not defined at HTMLTableRowElement.onclick ((index):1)

这是我在编辑器 View 中的代码:

<%@page import="java.sql.ResultSetMetaData"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.ResultSet"%>
<%
/*
...
Retrieving data of a database
*/
%>

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>

<body>
<div id="query_result">
<table id="table" >
<thead>
<tr>
<%
for(int i=1; i<=count; i++){
%><th class="mdl-data-table__cell--non-numeric"><%
out.print(metaData.getColumnName(i));
%></th><%
}
%>
</tr>
</thead>

<tbody>
<%
while(resultSet.next()){%>
<tr onclick="rowClickable(this)" class="n_title"> //<--error is on this line
<%for(int i= 1; i<= count; i++){
if(metaData.getColumnName(i).equals("PLANT")){
%><td data-bind="${resultSet.getString(i)}"><%
out.println("<a href='"+resultSet.getString(i)+"'>");
out.println(resultSet.getString(i));
out.println("</a>");
%></td><%
} else {
%><td data-bind="${resultSet.getString(i)}"><%
out.println(resultSet.getString(i));
%></td><%
}
}%>
</tr>
<%}
%>
</tbody>
</table>
</div>
<script type="text/javascript">
function rowClickable(x) {
alert("Row index is: " + x.rowIndex);
}
</script>
</body>
</html>

<% connection.close();
}
catch(Exception e){
out.println("\n<P> SQL error: <PRE> " + e + " </PRE> </P>\n ");
}
%>

这是我在浏览器 View 中的代码:

    <!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>

<body>
<div id="query_result">
<table id="table" >
<thead>
<tr>
<th class="mdl-data-table__cell--non-numeric">PLANT</th><th class="mdl-data-table__cell--non-numeric">NAME</th><th class="mdl-data-table__cell--non-numeric">FILES</th>
</tr>
</thead>

<tbody>

<tr onclick="rowClickable(this)" class="n_title">//<-- error is on this line
<td data-bind=""><a href='ABI'>ABI</a></td>
</tr>

</tbody>
</table>
</div>
<script type="text/javascript">
function rowClickable(x) {
alert("Row index is: " + x.rowIndex);
}
$("#")
</script>
</body>
</html>

我希望我的代码不会太乱 :D。如果有人能够解决我的问题,请提前致谢。

最佳答案

问题解决,脚本导入到主页面时,不是在ajax调用的页面上。

关于javascript - Uncaught ReferenceError - 找不到函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51492989/

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