高手请进:这段代码xmlhttp代码应该怎么写?

[复制链接]
查看11 | 回复2 | 2006-10-13 11:21:21 | 显示全部楼层 |阅读模式
好高深啊!!
回复

使用道具 举报

千问 | 2006-10-13 11:21:21 | 显示全部楼层
偏门问题,请不要上传
回复

使用道具 举报

千问 | 2006-10-13 11:21:21 | 显示全部楼层
【注】兄弟,你的代码怎么连格式都没有?还是在百度上不能显示正确格式?连一句注释都没有的代码,.....我就不说什么了,如果想做这方面的话必须写注释.you kown?这个是我blog的地址,上面有完整代码,非常适合你!http://www.cnblogs.com/AXzhz/archive/2006/10/09/524535.html【正文】这个是我帮你改的,因为没有环境,我没有环境,可能有些错误,你自己调试下!showRoles(obj)var http_request1 = false;//第一个XMLHttpRequest对象 var http_request2 = false;//第二个XMLHttpRequest对象 var processRequest=false;//创建XMLHttpRequest对象function creatXMLObject(http_request) { http_request = false;if(window.XMLHttpRequest){http_request = new XMLHttpRequest();if (http_request.overrideMimeType) { http_request.overrideMimeType("text/xml");} } else if (window.ActiveXObject){try { http_request = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) { try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (ei)
{}} } return http_request;}//入口函数function send_request(url1){ creatXMLObject(http_request1); //如果创建XMLHttpRequest对象失败 if (!http_request1){window.alert(" 不能创建对象.");return false; } else {http_request1.onreadystatechange = processRequest;http_request1.open("GET",url1, true);http_request1.send(null); }}//具体执行函数function processRequest() { if (http_request.readyState == 4){if (http_request.status == 200) { //根据返回值(字符串),判断是否有权限,这里我假设你知道怎么往回传值,返回值为:true/false var result = xmlHttp.responseText; if(!result) {
alert("该用户没有权限"); } else {
//从line2.asp中读取数据库内容
readData(); }
}else {
alert(" 页面有异常.");} }}//从line2.asp中读取数据库内容,与入口函数类似function readData(url2){ creatXMLObject(http_request2); //如果创建XMLHttpRequest对象失败 if (!http_request2){window.alert(" 不能创建对象.");return false; } else {http_request2.onreadystatechange = processRequest2;http_request2.open("GET",url2, true);http_request2.send(null); }}//有权限用户的具体执行函数function processRequest2() { if (http_request.readyState == 4){if (http_request.status == 200) { //result2为从line2.asp中读出的数据库内容 var result2 = xmlHttp.responseText; /*好了,数据有了,想怎么显示自己看着办吧*/}else {
alert(" 页面有异常.");} }}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行