转载:

做前端的,用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. javascript事件之:谈谈自定义事件

    对于JavaScript自定义事件,印象最深刻的是用jQuery在做图片懒加载的时候.给需要懒加载的图片定义一个appear事件.当页面图片开始出现时候,触发这个自定义的appear事件(注意,这里只 ...

  2. Head First 设计模式--1策略模式 组合优于继承

    策略模式:第一了算法族,分别封装起来,让他们之间可以互相替换,次模式让算法的变化独立于使用算法的客户. 首先看个错误的面向对象. 假如我们需要写一个关于鸭子的程序,各种类型的鸭子.第一想到的就是建一个 ...

  3. CentOS7 增加tomcat 启动,停止,使用systemctl进行配置

    1,centos7 使用 systemctl 替换了 service命令 参考:redhat文档: https://access.redhat.com/documentation/en-US/Red_ ...

  4. Java Integer的底层优化

    看一个程序(腾讯题) public class showMain { public static void main(String[] args){ //Double i1=127.00,i2=127 ...

  5. 使用ajax异步提交表单数据(史上最完整的版本)

    额 为啥用这个 不用form呢,因为这个效率高,而且在浏览器中运行程序的时候如果出现bug的话,页面不会显示显示错误信息,提高了用户的体验度. 那么,就来看看把,先给数据库表截个图哈 然后写项目被 我 ...

  6. Android doc打开太慢

    C:\Windows\System32\drivers\etc\HOSTS 127.0.0.1 fonts.googleapis.com 127.0.0.1 www.google.com 127.0. ...

  7. 线性布局通过适配器可以动态加载view

    因为适配器的getView的返回对象是view, 所以线性布局的对象可以通过addView动态加载适配器的getView 举例: mTestAdapter = new ListAdapter(this ...

  8. investopedia level 2

    Mispricing can be explained by the sum of the two components: true mispricing and estimation errorVe ...

  9. HDU 1106 排序 题解

    排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...

  10. 交换机的端口状态是UP,但是查询该端口下的MAC地址为空

    (电脑已关机)电脑与交换机直连的端口状态 还是 UP ,但是 查询该端口下的 MAC地址为空. 初步怀疑原因: Wake-on-LAN(电脑关机,网卡还在工作) Wake-On-LAN简称WOL,是一 ...