zoukankan      html  css  js  c++  java
  • 百度跨域ajax

    ajax.html

    <html>
    <head>
    <script>
    function ws_results(obj) {
    alert(obj.ResultSet.totalResultsAvailable);
    }

    </script>
    </head>
    <body>
    <SCRIPT LANGUAGE="JavaScript">
    var loginScript;
    <!--
    function G(id){if(typeof(id)=="string"){return document.getElementById(id);}return id;}
    function showInfo(obj){
        
    if(obj.checked == true){
            G(
    "memInfo").style.display="block";
        }
    else{
            G(
    "memInfo").style.display="none";
        }
    }
    function request(id,url){
         oScript 
    = document.getElementById(id);
         
    var head = document.getElementsByTagName("head").item(0);
         
    if (oScript) {
            head.removeChild(oScript);
         }
         oScript 
    = document.createElement("script");
         oScript.setAttribute(
    "src", url);
         oScript.setAttribute(
    "id",id);
         oScript.setAttribute(
    "type","text/javascript");
         oScript.setAttribute(
    "language","javascript");
         head.appendChild(oScript);
         
    return oScript;
    }
    var loginTimer=null;
    var loginState=-1;
    var tryTime=0;
    function PSP_ik(isOk){
        
    if(isOk==0){
            G(
    "errorInfo").style.display="none";
            loginState
    =1;
            
    if(parent.loginSuccess){
                parent.Pop.hide();
                parent.loginSuccess();
            }
        }
        
    else
        {
            loginFalse();
        }
    }

    function loginFalse(){
        loginState
    =0;
        
    var err=G("errorInfo");
        err.innerHTML
    ="用户名或密码错误,请重新登录";
        err.style.display
    ="block";
        G(
    "username").focus();
        tryTime
    ++;
        
    if(tryTime>1){
            onLoginFailed();
        }
    }
    function onLoginFailed(){
        
    if(parent.onLoginFailed){
            parent.Pop.hide();
            parent.loginFailed();
        }
    else{
            document.login.u.value
    =escape("http://zhidao.baidu.com/q"+parent.location.search);
            doucment.login.submit();
        }
            
    }
    function loginTimeout(){

        
    if(loginState==-1){
            
    var err=G("errorInfo");
            err.innerHTML
    ="操作超时,请重新登录";
            err.style.display
    ="block";
            G(
    "username").focus();
        }
    }

    function userLogin(){

        
    var url = 'http://uia.tel.comsys.net.cn/1.jsp?s='+(new Date()).getTime()+'&appid=YahooDemo&query=Madonna&output=json&callback=ws_results' ;
        loginState
    =-1;
        
    var login=request("loginScript",url);
        loginScript
    =login;
        login.onreadystatechange
    =function(){
                        
    var state = login.readyState; ;
                        
    if (state == "loaded" || state == "interactive" || state == "complete") {    
                            alert(msg);
    //msg与服务端返回的变量一致
                        } 
        }
        loginTimer 
    = setTimeout(loginTimeout, 5000);

    }
    window.onload
    =function(){
        
    }
    //-->
    </SCRIPT>


    <input onclick="userLogin()" type="button" value="userLogin"/>
    </body>
    </html>

    1.jsp

    <%@ page language="java" contentType="text/html; charset=gbk" %>
    var msg=<%=System.currentTimeMillis()%>
  • 相关阅读:
    [ html canvas save restore ] canvas绘图 save restore 属性理论讲解
    [ html canvas save restore ] canvas绘图 save restore 属性实例演示
    [ html canvas 绘制文本 ] canvas绘图实现绘制文本 strokeText fillText方法及textAlign textBaseline font 属性实例演示
    [ html canvas 旋转 缩放 平移 ] canvas绘图实现旋转复制实例演示
    [ html canvas 绘制曲线三种方法 ] canvas绘图 绘制曲线三种方法属性实例演示
    context.quadraticCurveTo() context.bezierCurveTo()详解
    sphinx教程 区段查询配置 命令(2)
    sphinx安装测试2
    fabric教程(1)
    NLPIR使用(1)
  • 原文地址:https://www.cnblogs.com/jifeng/p/2225595.html
Copyright © 2011-2022 走看看