버튼이있는 HTML 표가 있습니다. 버튼을 클릭하면 내 백엔드 서비스에 대한 GET 호출을 수행하는 ajquery 함수를 호출합니다.잡히지 않은 ReferenceError : jquery에 'abc'가 정의되어 있지 않습니다.
Html 페이지 행은 다음과 같이 생성됩니다.
!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" crossorigin="anonymous">
</script>
<style>
table, th, td {
border: 1px solid black;
}
</style>
<meta charset="UTF-8">
<title>Clients</title>
</head>
<body>
<table style="width:100%" id="clients_data">
<caption>Clients</caption>
<tr>
<th>Clients</th>
<th>Number of Sites</th>
<th>Reset the Processing</th>
</tr>
</table>
<!-- --Java script Functions -->
<script>
function loadCustomers() {
$.ajax({
type: 'GET',
url: 'http://localhost:8080/cache/getCustomers',
dataType: 'json',
success: function(data) {
var rows = [];
$.each(data,function(id,value) {
rows.push('<tr><td><a href="clientSiteInfo.html?client='+id+'">'+id+'</td><td>'+value+'</td><td><button type="button" onclick="reset('+id+')">Reset</td></tr>');
});
$('table').append(rows.join(''));
}
});
};
function reset(id) {
alert(id)
$.ajax({
type: 'GET',
url: 'http://localhost:8080/cache/reset?clientName='+id,
success: function(data) {
alert("Reset success")
}
});
};
window.onload = loadCustomers;
</script>
</body>
</html>
내 리셋 기능은 다음과 같습니다. 내가 버튼을 클릭 할 때
function reset(id) {
alert(id)
$.ajax({
type: 'GET',
url: 'http://localhost:8080/cache/reset?clientName='+id,
success: function(data) {
alert("Reset success")
}
});
};
, 나는 그것이
클릭 버튼 내가 도착하면 내 리셋() 함수에 'ID'값을 전달하는 기대;
ReferenceError: testClient is not defined
at HTMLButtonElement.onclick ((index):1)
onclick @ (index):1
무엇이 잘못 되었습니까?
어디에 질문에 코드를''태그를 닫는? – guest271314
testClient를 참조하는 코드 부분을 표시 할 수 있습니까? 그것이 오류를 치는 곳입니다. – Nick
표시된 코드에서 'testClient'와 아무런 관련이 없습니다. – charlietfl