| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2213 人关注过本帖
标题:ajax问题(急求助)
只看楼主 加入收藏
windful1000
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2006-2-23
收藏
 问题点数:0 回复次数:3 
ajax问题(急求助)
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
   
    <title>提取index.jsp的数据</title>
   
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">   
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
   <style type='text/css'>
    * { font-family: Tahoma, Arial, sans-serif; }
    #divId{ color: #48f; }
  </style>    
<script type="text/javascript">
   var XMLHttpReq;
   function createXMLHttpRequest(){
    if(window.XMLHttpRequest)
   XMLHttpReq = new XMLHttpRequest();
  else if(wondow.ActiveXObject)
    XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}

 function chuli(){
  if(XMLHttpReq.readyState == 4){
    if(XMLHttpReq.status == 200 || XMLHttpReq.status == 0){
        var divInfo = document.getElementById("divId");
        if(responseDataType != "Text")
           divInfo.innerHTML = XMLHttpReq.responseXML;
        else
           divInfo.innerHTML = XMLHttpReq.responseText;
    }else{
      window.alert("你所请求的页面有异常");
     }
  }
 }

 function lianjie(){
  var url="index.jsp";
  createXMLHttpRequest();
  XMLHttpReq.onreadystatechange = chuli;
  XMLHttpReq.open("GET",url,true);
  XMLHttpReq.send(null);
}  
</script>
  <!--
  <script type="text/javascript" src="prototype.js"/>
  <script type="text/javascript">
  window.onload=function(){
    new Ajax.Request(
      "index.jsp",
      {
              method:"post",
        onComplete:function(xhr){
          $('divId').innerHTML = xhr.responseText;
  }
    }
    );
 } ;  
  </script>
   -->
  </head>
  
  <body onLoad=lianjie();>
    <div id="divId">
        
    </div>
  </body>
</html>


index.jsp页面里有数据
可是我的这个页面取不到数据是什么原因啊
搜索更多相关主题的帖子: ajax 
2008-01-11 15:49
不惑
Rank: 2
等 级:论坛游民
威 望:2
帖 子:569
专家分:13
注 册:2007-3-22
收藏
得分:0 
function chuli(){
  if(XMLHttpReq.readyState == 4){
    if(XMLHttpReq.status == 200 || XMLHttpReq.status == 0){
        var divInfo = document.getElementById("divId");
        if(responseDataType != "Text")
           divInfo.innerHTML = XMLHttpReq.responseXML;
        else
           divInfo.innerHTML = XMLHttpReq.responseText;
    }else{
      window.alert("你所请求的页面有异常");
     }
  }
   window.alert(divInfo.innerHTML);
}
这样看看,它是不是真的没传过来
2008-02-13 15:12
ming206
Rank: 2
来 自:重庆
等 级:等待验证会员
威 望:3
帖 子:545
专家分:7
注 册:2005-8-2
收藏
得分:0 
在:
var divInfo = document.getElementById("divId");下

加:

var scripts = document.getElementById(divInfo).getElementsByTagName("SCRIPT");
                for (var i = 0; i < scripts.length; i++)
                {
                    if (scripts[i].tagName == "SCRIPT")
                    {
                        scripts[i].src = scripts[i].src;
                        scripts[i].defer = true;
                        scripts[i].type =  "text/javascript";
                    }
                }

外贸综合平台:E贸通
2008-02-18 16:45
ming206
Rank: 2
来 自:重庆
等 级:等待验证会员
威 望:3
帖 子:545
专家分:7
注 册:2005-8-2
收藏
得分:0 
弹出有东西,你自己看:



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    <title>提取index.jsp的数据</title>
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
   <style type='text/css'>
    * { font-family: Tahoma, Arial, sans-serif; }
    #divId{ color: #48f; }
  </style>   
<script type="text/javascript">
   var XMLHttpReq;
   function createXMLHttpRequest(){
     if(window.XMLHttpRequest){
         XMLHttpReq = new XMLHttpRequest();
      }
         else if(window.ActiveXObject){
         try{
             XMLHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
            }catch(e){}
         }
}

function chuli(){
  if(XMLHttpReq.readyState == 4){
    if(XMLHttpReq.status == 200){
        var divInfo = document.getElementById("divId");
        var scripts = divInfo.getElementsByTagName("SCRIPT");        
                 for (var i = 0; i < scripts.length; i++)
                 {
                      if (scripts[i].tagName == "SCRIPT")
                      {
                            scripts[i].src = scripts[i].src;
                            scripts[i].defer = true;
                            scripts[i].type =  "text/javascript";
                      }
                 }
            alert(XMLHttpReq.responseText);
              divInfo.innerHTML = XMLHttpReq.responseText;
    }else{
      window.alert("你所请求的页面有异常");
     }
  }
}

function lianjie(){
  var url="index.jsp";
  createXMLHttpRequest();
  XMLHttpReq.onreadystatechange = chuli;
  XMLHttpReq.open("GET",url,true);
  XMLHttpReq.send(null);
}  
</script>
  </head>
  <body onLoad=lianjie();>
    <div id="divId"></div>
  </body>
</html>

外贸综合平台:E贸通
2008-02-18 17:03
快速回复:ajax问题(急求助)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.086925 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved