利用SSH框架如何使用Ajax在JSP页面取得数据库里的数据,请教大家了!
3个回答
展开全部
你参照这个例子做下试试,把请求方法修改成Struts的就是了
function checklogin(){
if(loginName.value!=""){
//创建XMLHttpRequest对象
http_request = false;
if (window.XMLHttpRequest) {
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('不能创建 XMLHTTP 实例');
return false;
}
http_request.onreadystatechange = CheckGroupName; //onreadyStateChange事件可指定一个事件处理函数来处理XMLHttpRequest对象的执行结果
http_request.open('POST', "/rdflz/UsersAction.do?method=checkLoginUser&login_name="+loginName.value, true);//设置请求方法及目标,并且设置为异步提交
http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");//单独设定某个请求的HTTP头信息
http_request.send(null);//发送请求
return false;
}else{
alert("请输入用户名");
}
}
function CheckGroupName() {
}
function checklogin(){
if(loginName.value!=""){
//创建XMLHttpRequest对象
http_request = false;
if (window.XMLHttpRequest) {
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('不能创建 XMLHTTP 实例');
return false;
}
http_request.onreadystatechange = CheckGroupName; //onreadyStateChange事件可指定一个事件处理函数来处理XMLHttpRequest对象的执行结果
http_request.open('POST', "/rdflz/UsersAction.do?method=checkLoginUser&login_name="+loginName.value, true);//设置请求方法及目标,并且设置为异步提交
http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");//单独设定某个请求的HTTP头信息
http_request.send(null);//发送请求
return false;
}else{
alert("请输入用户名");
}
}
function CheckGroupName() {
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询