I have set up a table in JSP and am attempting to trigger a function when clicking on the table rows to post the data. I created a JavaScript file with an ajax click event, but unfortunately, the event is not being fired.
$(document).ready(function() {
$(document).on("click",'.outi',(function(MyObj)
{ var Myjson = JSON.stringify(MyObj);
$.ajax({
// POST Method
method: "POST",
// URL
url: "Client_frameServlet",
// Asynchronous mode to wait for the end of the ajax before continuing
async: false, // Synchronous mode
// Sending data
data: Myjson ,
dataType: "json" ,
success: function() {
alert('In Ajax');
}
})
}));
});
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<META HTTP-EQUIV="expires" CONTENT="0">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META http-equiv="Content-Type" content="text/html; charset="iso-8859-1">
<head>
<title>TX06</title>
<link rel='stylesheet' type='text/css' href='style.css'>
<script src="date.js"></SCRIPT>
</head>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"
></script>
<script src="res_gen.js">
</script>
<body>
<table width="100%" align="center" border=0 cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="95%" align="center" border=0 cellspacing="0" cellpadding="0">
<tr>
<td class="titre">Résultat de la recherche</td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<table border=0 bgcolor=#92ADC2 cellspacing=1 cellpadding=3 width=95% align=center>
<tr class=entete>
<td class=texte8 align=center> Nom</td>
<td class=texte8 align=center> Date de naissance</td>
<td class=texte8 align=center> Coll</td>
<td class=texte8 align=center> Numéro</td>
<td class=texte8 align=center> Numéro contact</td>
<td class=texte8 align=center> TITULAIRE</td>
</tr>
<tr class="outi" onMouseOver="this.className='over';" onMouseOut="this.className='outi';">
<td class=texte7 align=left colspan=5> Aucun client ne trouve</td>
</tr>
</table>
<br>
<table width="95%" align="center" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right">
<a target="corps" href="gen_rech.jsp" class="rub2" onmouseover="voltar.src = '../images/fr/voltar_s.gif';" onmouseout="voltar.src = '../images/fr/voltar.gif';"><img src="../images/fr/voltar.gif" border="0" name=voltar ></a>
</td>
</tr>
</table>
</body>
</html>
PS: I have attempted calling by classname without success and have verified browser parameters to confirm that the event is indeed not being triggered.