public String hotWeek() throws Exception{
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/xml; charset=gb2312");
PrintWriter out = response.getWriter();
StringBuffer insertHotHtml = new StringBuffer();
insertHotHtml.append(" <table width=171 border=0 align=center cellpadding=0
cellspacing=0> ");
insertHotHtml.append("<tr> ");
insertHotHtml.append("<td width=23 height=25></td> ");
insertHotHtml.append("</tr> ");
insertHotHtml.append("</table> ");
out.print(insertHotHtml.toString()); //返回一个有表格的HTTP报文
return null;
}
var xmlHttp;
function createXMLHttpRequest(){
if (window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function startAjaxRequest(method,async,actionUrl,data, invokeMethod){
createXMLHttpRequest();
xmlHttp.open(method, actionUrl, async);
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.send(data);
function handleStateChange(){
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
var nodeId = xmlHttp.responseText;
if (nodeId=='noPermission'){
alert('你没有权限访问此操作!');
}else if( (falseIndex = nodeId.indexOf("false||"))!= -1 ){
alert('操作失败,可能的原因为:' + nodeId.substring(
falseIndex+7, nodeId.length) + "!");
}else if(nodeId=='false'){
alert('操作失败,请和管理员联系!');
}else ...{
if (invokeMethod == undefined){
getResult(nodeId);
} else {
invokeMethod(nodeId);
}
}
}
}
}
}
$(document).ready(function(){
var actionUrl = "./provider!hotWeek.action";
$('body').html("<strong>页面加载中...</strong>");
startAjaxRequest("GET",true,actionUrl,'');
});
function getResult(nodeId){
$('body').html(nodeId);
}