Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set the values from the ajax to the table in jsp
    primarykey
    data
    text
    <p>I am having one jsp with a table,and in that i have two columns called status and numRecords. i am getting new status and numrecords values thru ajax. what i want to is replace status and numrecords of the table with the newly retrieved values on ajax. I have tried like this,this is my jsp:</p> <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%&gt; &lt;%@ taglib prefix="s" uri="/struts-tags"%&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;File Upload&lt;/title&gt; &lt;script type="text/javascript" src="js/jquery.min.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" type="text/css" href="css/style1.css" /&gt; &lt;link rel="stylesheet" type="text/css" href="css/button.css" /&gt; &lt;link href="css/common-style.css" rel="stylesheet" type="text/css" /&gt; &lt;style&gt; a{ color:white; text-decoration:none; } &lt;/style&gt; &lt;script type="text/javascript"&gt; var id; function refreshRecord(value) { id = value; alert(id); } $(document).ready(function(){ $("#refresh").click(function(){ var fileId=id; alert("ajax id is "+fileId); $.ajax({ type:'post', url:'checkStatusAndNumRecs', data:{fileId:fileId}, success:function(data) { var obj=data.split(':'); alert("status is :"+obj[0]); $("#stat").html(obj[0]); $("#recs").html(obj[1]); }, error:function(data) { $("#div1").html("It was a failure !!!"); } }); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;%@include file="index1.html" %&gt; &lt;div class="box2"&gt; &lt;div class="box3"&gt; &lt;s:property value="userId"/&gt; &lt;/div&gt; &lt;center&gt;&lt;h2&gt;FILE STATUS&lt;/h2&gt;&lt;/center&gt; &lt;center&gt; &lt;form action="Upload" method="post" enctype="multipart/form-data"&gt; &lt;label for="myFile" class="text"&gt;Upload your file:&lt;/label&gt; &lt;input type="hidden" name="upload" value="upload"/&gt; &lt;input type="file" name="myFile" size="40" class="file"/&gt; &lt;input type="submit" value="Upload" class="button"/&gt; &lt;input type="submit" value="Refresh" class="button"/&gt; &lt;/form&gt; &lt;/center&gt; &lt;center&gt; &lt;table border="1" class="displaytab" id="rtable"&gt; &lt;s:if test="%{user.roles == 'admin'}"&gt; &lt;tr&gt; &lt;td colspan="10" style="background:#7395B8;color:white;font-size:18px;font-weight:bold;"&gt;&lt;center&gt;Admin&lt;/center&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/s:if&gt; &lt;tr&gt; &lt;th&gt;FileId&lt;/th&gt;&lt;th&gt;File Name&lt;/th&gt;&lt;th&gt;Upload Date&lt;/th&gt;&lt;th&gt;#Records&lt;/th&gt;&lt;th&gt;Status&lt;/th&gt;&lt;th&gt;Estimated Time&lt;/th&gt;&lt;th&gt;Processed Records&lt;/th&gt;&lt;th&gt;Generate Report&lt;/th&gt;&lt;th&gt;&lt;/th&gt;&lt;s:if test="%{user.roles == 'admin'}"&gt;&lt;th&gt;Controls&lt;/th&gt;&lt;/s:if&gt; &lt;/tr&gt; &lt;s:iterator value="uploadList" var="m"&gt; &lt;tr&gt; &lt;td&gt;&lt;s:property value="%{#m.fileId}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;s:property value="%{#m.fileName}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;s:property value="%{#m.uploadDate}" /&gt;&lt;/td&gt; &lt;td id="recs"&gt;&lt;s:property value="%{#m.numRecords}" /&gt;&lt;/td&gt; &lt;td id="stat"&gt;&lt;s:property value="%{#m.status}" /&gt;&lt;/td&gt; &lt;td&gt;tbd&lt;/td&gt; &lt;td&gt;&lt;s:property value="%{#m.numRecords}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;a href=""&gt;&lt;img src="images/generate.png" title="Generate Report"&gt;&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a href=""&gt;&lt;img src="images/refresh.png" title="Refresh" id="refresh" onclick="refreshRecord(&lt;s:property value="%{#m.fileId}" /&gt;);"&gt;&lt;/a&gt;&lt;/td&gt; &lt;s:if test="%{user.roles == 'admin'}"&gt; &lt;td&gt;&lt;a href=""&gt;&lt;img src="images/details.png"&gt;&lt;/a&gt; &lt;a href=""&gt;&lt;img src="images/plus.png" title="Add Instance"&gt;&lt;/a&gt; &lt;a href=""&gt;&lt;img src="images/minus.png" title="Remove Instance"&gt;&lt;/a&gt; &lt;a href=""&gt;&lt;img src="images/download.png" title="Download"&gt;&lt;/a&gt; &lt;a href=""&gt;&lt;img src="images/reconnect.png" title="Reconnect"&gt;&lt;/a&gt;&lt;/td&gt; &lt;/s:if&gt; &lt;/tr&gt; &lt;/s:iterator&gt; &lt;/table&gt; &lt;/center&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;center&gt; &lt;s:if test="%{user.roles == 'admin'}"&gt; &lt;!-- &lt;select name="user names"&gt; &lt;s:iterator value="userNamesList"&gt; &lt;option value="emailColumn" &gt; &lt;s:property/&gt; &lt;/option&gt; &lt;/s:iterator&gt; &lt;/select&gt; --&gt; &lt;table border="1" class="displaytab" id="usertab"&gt; &lt;s:if test="%{uploadListMap.size() != 0}"&gt; &lt;tr&gt; &lt;td colspan="10" style="background:#7395B8;color:white;font-size:18px;font-weight:bold;"&gt;User Job Details&lt;/center&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;th&gt;FileId&lt;/th&gt;&lt;th&gt;File Name&lt;/th&gt;&lt;th&gt;Upload Date&lt;/th&gt;&lt;th&gt;#Records&lt;/th&gt;&lt;th&gt;Status&lt;/th&gt;&lt;th&gt;Estimated Time&lt;/th&gt;&lt;th&gt;Processed Records&lt;/th&gt;&lt;th&gt;Generate Report&lt;/th&gt;&lt;th&gt;&lt;/th&gt;&lt;s:if test="%{user.roles == 'admin'}"&gt;&lt;th&gt;Controls&lt;/th&gt;&lt;/s:if&gt; &lt;/tr&gt; &lt;s:iterator value="%{uploadListMap}"&gt; &lt;tr&gt; &lt;td colspan="10" style="background:#7395B8;color:white;font-size:18px;font-weight:bold;"&gt;&lt;center&gt;&lt;s:property value="key"/&gt;&lt;/center&gt;&lt;/td&gt; &lt;s:iterator value="value" var="u"&gt; &lt;tr&gt; &lt;td&gt;&lt;s:property value="%{#u.fileId}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;s:property value="%{#u.fileName}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;s:property value="%{#u.uploadDate}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;s:property value="%{#u.numRecords}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;s:property value="%{#u.status}" /&gt;&lt;/td&gt; &lt;td&gt;tbd&lt;/td&gt; &lt;td&gt;&lt;s:property value="%{#m.numRecords}" /&gt;&lt;/td&gt; &lt;td&gt;&lt;a href=""&gt;&lt;img src="images/generate.png" title="Generate Report"&gt;&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a href=""&gt;&lt;img src="images/refresh.png" title="Refresh" id="refresh" onclick="refreshRecord(&lt;s:property value="%{#u.fileId}" /&gt;);"&gt;&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a href=""&gt;&lt;img src="images/details.png"&gt;&lt;/a&gt; &lt;a href=""&gt;&lt;img src="images/plus.png" title="Add Instance"&gt;&lt;/a&gt; &lt;a href=""&gt;&lt;img src="images/minus.png" title="Remove Instance"&gt;&lt;/a&gt; &lt;a href=""&gt;&lt;img src="images/download.png" title="Download"&gt;&lt;/a&gt; &lt;a href=""&gt;&lt;img src="images/reconnect.png" title="Reconnect"&gt;&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/s:iterator&gt; &lt;/tr&gt; &lt;/s:iterator&gt; &lt;/s:if&gt; &lt;/table&gt; &lt;/s:if&gt; &lt;/center&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>please help me in this,thanks in advance. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload