In my jsp page I have a table. And in that table I am putting some data from db as shown below:
<tbody>
<c:forEach var="row" items="${result.rows}">
<tr onclick="toggle(this)">
<td>${row.SCHEDULE_NAME}</td>
<td>${row.SCHEDULE_TYPE}</td>
<td>${row.SERVICE_NAME}</td>
<td>${row.INTERVAL_TIME}</td>
<td>${row.CREATED_BY}</td>
<td>${row.UPDATED_BY}</td>
<td>${row.LOCK_UNLOCK}</td>
<td>${row.RUNNING_FLAG}</td>
<td>${row.LAST_FETCH_NEEDED}
<a id="header" href="${pageContext.request.contextPath}/test?db=${row.RULE_ID}"><img src="img\serch.png" alt="^" height="10" width="10" align="right"></a>
</td>
</c:forEach>
</tbody>
In href tag I am getting one value db=somevalue and in my servlet I am picking this value and perform some operation and send it back to test area
How to perform this operation via Ajax call
Help me?
You can do the following
<a href="www.mysite.com" >Item</a>
<a id="header" href="${pageContext.request.contextPath}/test?db=${row.RULE_ID}" onclick="return myAjaxFunction();"><img src="img\serch.png" alt="^" height="10" width="10" align="right"></a>
<script type="text/javascript">
function myAjaxFunction () {
//make the ajax call
// return true or false, depending on whether you want to allow the `href` property to be called or not
}
</script>
Do not forget to return true or false from the method.