+ -
当前位置:首页 → 问答吧 → Ajax 获取返回值具体的字段如何获取?

Ajax 获取返回值具体的字段如何获取?

时间:2010-09-25

来源:互联网

我的js如下:
想取http://dict.cn/hello
的翻译内容
应该如何获取.谢谢高人

JScript code

function test(){
    var xmlHttp ;
    try{
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
 
        var web = "http://dict.cn/hello";
 
        //异步方式
        xmlHttp.open("GET",web,true);
        
        xmlHttp.onreadystatechange = function(){
       // alert(xmlReq.readystate);
              if (xmlHttp.readystate == 4){
                      document.write(xmlHttp.responseText);
              }
 
        }
 
        xmlHttp.send();
      //  alert(xmlHttp.responseText);
        window.clipboardData.setData("Text",xmlHttp.responseText);
      //   alert(xmlReq.responseText);
 }
    catch(e){
       
         alert(e);
    }
    
}

作者: meiyoudao   发布时间: 2010-09-25

跨域了,而且这个网站的内容使用的是ajax动态生成的,即使使用代理也获取不到ajax生成的内容

你需要使用winform编程中的webbrowser控件来解析最后包括ajax生成html代码获取内容

参考
谁能帮我抓取这个网页里的指定部分的内容?

作者: showbo   发布时间: 2010-09-25

JScript code
function test(){
    var xmlHttp ;
    try{
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        var web = "http://dict.cn/hello"; 
        //异步方式
        xmlHttp.open("GET",web,true);        
        xmlHttp.onreadystatechange = function(){
              //  alert(xmlHttp.responseText);
             window.clipboardData.setData("Text",xmlHttp.responseText);//这个在回调里执行
      //   alert(xmlReq.responseText);
       // alert(xmlReq.readystate);
              if (xmlHttp.readystate == 4){
                      document.write(xmlHttp.responseText);
              }
 
        }
 
        xmlHttp.send();      
 }
    catch(e){       
         alert(e);
    }    
}

作者: IBM_hoojo   发布时间: 2010-09-25

我想写成firefox插件的. 所以不是用java获取. 最好是JS直接获取.

作者: meiyoudao   发布时间: 2010-09-25