zoukankan      html  css  js  c++  java
  • netty服务器和跨域访问

    火狐3.5以上

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <title>孟宪会之AJAX跨域请求测试</title>
     </head>
    <body>
      <input type='button' value='开始测试' onclick='crossDomainRequest()' />
      <div id="content"></div>

      <script type="text/javascript">
        //<![CDATA[
        var xhr = new XMLHttpRequest();
        var url = 'http://192.168.0.94:8080/now.php';
        function crossDomainRequest() {
          document.getElementById("content").innerHTML = "开始……";
          if (xhr) {
            xhr.open('GET', url, true);
            xhr.onreadystatechange = handler;
            xhr.send();
          } else {
            document.getElementById("content").innerHTML = "不能创建 XMLHttpRequest";
          }
        }
        function handler(evtXHR) {
          if (xhr.readyState == 4) {
            if (xhr.status == 200) {
              var response = xhr.responseText;
              document.getElementById("content").innerHTML = "结果:" + response;
            } else {
              document.getElementById("content").innerHTML = "不允许跨域请求。";
            }
          }
          else {
            document.getElementById("content").innerHTML += "<br/>执行状态 readyState:" + xhr.readyState;
          }
        }
        //]]>
      </script>

    </body>
    </html>

    下面是IE8上以的

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head>  
      <title>孟宪会之AJAX跨域请求测试</title>  
    </head>  
    <body>  
      <input type='button' value='开始测试' onclick='crossDomainRequest()' />  
      <div id="content"></div>  
      <mce:script type="text/javascript">
      <!-- 
       
       //--></mce:script>  
       <script type="text/javascript">
        var xhr = new XDomainRequest();   
        var url = 'http://192.168.0.94:8080/now.php'; 
        function crossDomainRequest() {   
          document.getElementById("content").innerHTML = "开始……";   
          if (xhr) {   
            xhr.open('GET', url);   
            xhr.onload = handler;   
            xhr.send();   
          } else {   
          document.getElementById("content").innerHTML = "不能创建 XDomainRequest";   
          }   
        }   
        function handler(evtXHR) {   
          document.getElementById("content").innerHTML = "结果:" + xhr.responseText;   
        }   
      </script>
    </body>  
    </html>

  • 相关阅读:
    xtrabackup之Innobackupex全备数据库
    没有Where条件下group by走索引
    Oracle中查看无效的对象、约束、触发器和索引
    udev/raw/asmlib/多路径 配置asm
    自适应游标共享技术02(一个简单的例子来走近ACS)
    自适应游标共享技术03(常用分析脚本)
    监控进程是否存在
    MySQL运行状态show status详解
    MySQL 加锁处理分析
    使用RMAN验证备份的有效性
  • 原文地址:https://www.cnblogs.com/gyxdbk/p/1903825.html
Copyright © 2011-2022 走看看