a.jsp页面
<script type="text/javascript">
var xmlHttp = null;
function createXmlHttp(){
if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
else if(window.ActiveXObject){
try{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")
}catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
alert("Microsoft.XMLHTTP")
} catch (e) {alert("浏览岂不支持")}
}
}
}
function proccer(){
var inputObj=document.getElementById("cont")
var value=inputObj.value;
var url="b.jsp?content="+value;
xmlHttp.onreadystatechange=callback;
//get方式传值url="b.jsp?content="+value
xmlHttp.open("get",url,true);
xmlHttp.send(null);
}
function callback(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
document.getElementById("div").innerHTML=xmlHttp.responseText;
}
}
}
</script>
<body οnlοad=" createXmlHttp()">
<div id="div"></div>
<p>dlgjlfjhklgtji</p>
<p>fglfjytkjhu</p>
<form action="">
<input id="cont" type="text" name="content" οnkeyup="proccer()"/>
</form>
</body>
b.jsp
<body>
//接受get方式传的值request.getParameter("content") ;
<img alt="" src="image/<%=request.getParameter("content") %>.jpg">
<p><%=request.getParameter("content")%></p>
</body>