- JSP로 새로 생겼습니다. mySQL 데이터베이스에서 데이터를 검색하는 데 XMLHTTP를 사용하고 있지만 데이터를 업데이트 한 후에는 업데이트 된 데이터가 아닌 이전 데이터 만 표시합니다. 솔루션입니다. 라디오 버튼이 있습니다.XMLHTTP로 새로 고침 문제
<td class="inputs_new"> <div id = "UT2">
<%
for (int i = 0; i < thinClientName.size(); i++) {
%>
<input type = "radio" class = "my-button2" onclick="get()" id = "thinClnt_rad" name ="thinClnt_rad" value = "<%=thinClientName.get(i)%>" >
<%
out.println(thinClientName.get(i));
}
%>
</div>
//Get function
function get()
{
var save_thin = "";
for (var i = 0; i < document.getElementsByName('thinClnt_rad').length; i++)
{
if (document.getElementsByName('thinClnt_rad')[i].checked)
{
save_thin = document.getElementsByName('thinClnt_rad')[i].value;
}
}
var xmlhttp= GetXmlHttpObject1();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
var respTest = xmlhttp.responseText;
var res = respTest.split(";");
document.getElementById("thinClientName").value=res[0];
document.getElementById("Model").value=res[1];
document.getElementById("SrNo").value=res[2];
document.getElementById("ProductID").value=res[3];
document.getElementById("sprNo").value=res[4];
document.getElementById("MacAdd").value=res[5];
document.getElementById("IPAdd").value=res[6];
document.getElementById("Script").value=res[7];
document.getElementById("VedName").value =res[10] ;
document.getElementById("playtime").value = res[11] ;
var sid_2=res[8];
var options= document.getElementById('lstLocation').options;
for (var i= 0; i <options.length ; i++)
{
if (options[i].text==sid_2) {
document.getElementById("lstLocation").selectedIndex = i;
}
}
var sid_21=res[9];
var options= document.getElementById('state').options;
for (var i= 0; i <options.length ; i++)
{
if (options[i].text==sid_21) {
document.getElementById("state").selectedIndex = i;
}
}
}
}
xmlhttp.open("GET","GetData.jsp?q="+save_thin,true);
xmlhttp.send(null);
}
function GetXmlHttpObject1()
{
if (window.XMLHttpRequest)
{
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
// and getData.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import = "java.io.*,java.sql.*" %>
<%@page import= "jdbc.DBConnection" %>
<%
String str=request.getParameter("q");
try
{
DBConnection con_obj = new DBConnection();
Connection con = con_obj.getConnection();
Statement stmtThinInfo = null;
Statement stmt_play = null;
ResultSet rsThinInfo = null;
ResultSet rs_play = null;
String q =request.getParameter("q");
stmtThinInfo = con.createStatement();
rsThinInfo = stmtThinInfo.executeQuery("select * from thinclient_tbl where name = '"+q+"'");
while (rsThinInfo.next())
{
stmt_play = con.createStatement();
rs_play = stmt_play
.executeQuery("Select * from thin_videotable where Thin_Client = '"
+ q + "'");
String outPut;
if (rs_play.next()) {
outPut = rsThinInfo.getString("name") + ";" + rsThinInfo.getString("modell") + ";" + rsThinInfo.getString("serialnumber") + ";" + rsThinInfo.getString("product_id") + ";" + rsThinInfo.getString("spare_nr")+ ";" + rsThinInfo.getString("MAC-Adresse") + ";" + rsThinInfo.getString("IP-Adresse") + ";" + rsThinInfo.getString("script") + ";" + rsThinInfo.getString("location")+ ";" + rsThinInfo.getString("state") + ";" + rs_play.getString("VideoName") + ";" + rs_play.getString("Video_time");
response.getWriter().write(outPut);
System.out.println(outPut);
}
else
{
outPut = rsThinInfo.getString("name") + ";" + rsThinInfo.getString("modell") + ";" + rsThinInfo.getString("serialnumber") + ";" + rsThinInfo.getString("product_id") + ";" + rsThinInfo.getString("spare_nr")+ ";" + rsThinInfo.getString("MAC-Adresse") + ";" + rsThinInfo.getString("IP-Adresse") + ";" + rsThinInfo.getString("script") + ";" + rsThinInfo.getString("location")+ ";" + rsThinInfo.getString("state") + ";" ;
response.getWriter().write(outPut);
System.out.println(outPut);
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
%>
제안 사항이 있으면 알려주십시오.
사람들이 당신을 도울 수 있도록 몇 가지 코드를 공유해야합니다. – Relequestual
라디오 버튼이 있습니다. –
코드를 포함하려면 질문을 편집해야합니다. 사람들이 당신을 도울 수 있도록 귀하의 질문에 충분한 정보가 없습니다. – Relequestual