转载:

做前端的,用Ajax获取数据,是常有的事情,同域下自然没问题了,如果是不同域获取数据,浏览器就有个同源策略的限制

如图:

Origin * is not allowed by Access-Control-Allow-Origin

有人会说用JSONP了。如果后台的数据接口只是返回单纯的json数据呢,而且也不能修改符合JSONP的方式的数据形式。 这个时候,我们该怎么办呢? 如果你用的浏览器是Chrome的话,那么就有福音了。在打开Chrome的地址后边加上 --args --disable-web-security --user-data-dir 就可以屏蔽安全访问了[ --args:此参数可有可无],然后就随意的调用不同域下的数据了。

具体操作步骤如下:

一:windows系统(Win7)下的Chrome

1、关闭所有打开的Chrome。(重要)。否则,将没有效果!

2、创建Chrome的快捷方式,修改快捷方式的目标为:

"C:\Program Files\Google\Chrome\Application\chrome.exe" --args --disable-web-security

如图:

3、双击我们创建的Chrome快捷方式,打开Chrome,如图出现“您使用的是不受支持的命令行标记:--disable-web-security。稳定性和安全性会有所下降”,表示你取消了跨域限制了,可以随意跨域调用数据了。

如图:

Mac os 下面用

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --disable-web-security

或者

open -a "Google Chrome" --args --disable-web-security

Ubuntu?Linux:

chromium-browser --disable-web-security

用命令行打开 Apple Safafi 方法是:(Mac OS 下)

open -a '/Applications/Safari.app' --args --disable-web-security

此致完结。谢谢观赏。如有问题,请留言!

chrome 49 版本 跨越 --args --disable-web-security --user-data-dir的更多相关文章

  1. chrome 49 版本bug: flex父元素设置flex:1 , 子元素用height:100%无法充满父元素

    1 <div class="container"> <div class="item"> <div class="ite ...

  2. ref:web security最新学习资料收集

    ref:https://chybeta.github.io/2017/08/19/Web-Security-Learning/ ref:https://github.com/CHYbeta/Web-S ...

  3. [Security] Web Security Essentials

    In this course, we'll learn how to exploit and then mitigate several common Web Security Vulnerabili ...

  4. Portswigger web security academy:Reflected XSS

    Portswigger web security academy:Reflected XSS 目录 Portswigger web security academy:Reflected XSS Ref ...

  5. Portswigger web security academy:Cross-origin resource sharing (CORS)

    Portswigger web security academy:Cross-origin resource sharing (CORS) 目录 Portswigger web security ac ...

  6. Portswigger web security academy:Cross-site request forgery (CSRF)

    Portswigger web security academy:Cross-site request forgery (CSRF) 目录 Portswigger web security acade ...

  7. Portswigger web security academy:SQL injection

    Portswigger web security academy:SQL injection 目录 Portswigger web security academy:SQL injection SQL ...

  8. SPRING SECURITY JAVA配置:Web Security

    在前一篇,我已经介绍了Spring Security Java配置,也概括的介绍了一下这个项目方方面面.在这篇文章中,我们来看一看一个简单的基于web security配置的例子.之后我们再来作更多的 ...

  9. System.Web.Security 在winform中是什么命名空间呢

    des.Key = ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStorin ...

随机推荐

  1. 《BI那点儿事》META DATA(元数据)

    关于数据仓库的数据,指在数据仓库建设过程中所产生的有关数据源定义,目标定义,转换规则等相关的关键数据.同时元数据还包含关于数据含义的商业信息,所有这些信息都应当妥善保存,并很好地管理.为数据仓库的发展 ...

  2. wenti

    No apport report written because MaxReports is reached already                                       ...

  3. android studio gradle升级

    http://services.gradle.org/distributions 下载最新的gradle-3.0-all.zip包 放入C:\Users\Administrator\.gradle\w ...

  4. Objective-C(内存管理)

    引用计数器 每个OC对象都有一个占4个字节存储空间的引用计数器 当使用或创建一个对象时,新对象的引用计数器默认是1 retain:可以使引用计数器+1 release:可以是引用计数器-1 retai ...

  5. WCF初探-8:WCF服务承载 (上)

    前言 任何一个程序的运行都需要依赖一个确定的进程中,WCF服务也不例外.如果使用WCF服务,我们就必须将服务承载于创建它并控制它的上下文和生存期的运行时环境中,承载服务环境的程序,我们称之为宿主.WC ...

  6. 把字典的key value 拼接成字符串加上签名加密

    - (NSString *)getSianKeyWithDic:(NSDictionary *)dic { //按字典排序 NSArray* arr = [dic allKeys]; arr = [a ...

  7. 1427. SMS

    http://acm.timus.ru/problem.aspx?space=1&num=1427 没想到这道题错了N遍  细节很重要呀 代码: #include<iostream> ...

  8. jquery ajax跨域请求webservice webconfig配置

    <configuration> <system.web> <compilation debug="true" targetFramework=&quo ...

  9. [TD Cup 2014] TDL的YC牌 & TDL的幼儿园

    TDL的YC牌 传说中的置换群?反正不懂.我的思路竟然是对的,可是为何只有20分? (1)尼玛每行数据输出后回车不打! (2)写gcd函数脑残把a mod b写成a-b,大大减慢速度… (3)看标程才 ...

  10. 使用 HttpClient 和 HtmlParser 实现简易爬虫

    这篇文章介绍了 HtmlParser 开源包和 HttpClient 开源包的使用,在此基础上实现了一个简易的网络爬虫 (Crawler),来说明如何使用 HtmlParser 根据需要处理 Inte ...