zoukankan      html  css  js  c++  java
  • (CORS)跨域资源共享方案

    在XMLHttpRequest对象访问跨域资源的时候的一些被认可的跨域访问资源的方案叫

    (CORS)跨域资源共享方案。

    在ie8中,可以通过XDomainRequest进行CORS,而在其他的浏览器中可以通过XHR对象

    即可进行CORS。

    代码取自javascript高级程序设计3版:

     1 function aCORSRequest(method,url){
     2     
     3     var xhr = new XMLHttpRequest();
     4     
     5     if('withCredentials' in xhr){
     6         //准备请求
     7         xhr.open(method,url,true);    
     8     }else if(typeof XDomainRequest != 'undefined'){
     9         
    10         xhr = new XDomainRequest();
    11         
    12         xhr.open(method,url);
    13         
    14     }else{
    15         xhr = null;    
    16     }
    17     
    18     return xhr;
    19     
    20     
    21 }
  • 相关阅读:
    工厂增强
    面试题
    SpringBean生命周期及作用域
    字符串
    带参数方法实例
    带参数方法
    人机猜拳
    类的无参方法
    类和对象实例2
    类和对象实例1
  • 原文地址:https://www.cnblogs.com/hellome/p/4026969.html
Copyright © 2011-2022 走看看