-------------------------jsp中的js代码--------------------
<script type="text/javascript">
function ajaxFunction(sort){
var xmlHttp;
try{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
} catch (e)
{
// Internet Explorer
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch (e)
{
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch (e)
{
alert("您的浏览器不支持AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
document.getElementById("div_product").innerHTML=xmlHttp.responseText;
}
}
xmlHttp.open("POST","problemAction.do?action=showVersions",true);
xmlHttp.send(null);
}
</script>
----------------------------action中代码-------------------------
public String showVersions(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String content ="<select id='qbbh' name='qbbh'>";
content = content + "<option value=''>--请选择--</option>";
for(int i=0;i<5;i++){
content = content + "<option value='"+ i +"'>"+ i +"</option>";
}
content = content + "</select>";
response.setContentType( "text/html" );
response.setCharacterEncoding( "GBK" );
response.getWriter().write(content);
return null;
}