文章内容
2017/12/20 9:36:07,作 者: 黄兵
解决“No 'Access-Control-Allow-Origin' header is present on the requested resource”
1. 问题描述
在js中使用ajax请求在网页控制台下打印以下错误信息:
XMLHttpRequest cannot load http://192.168.2.46:8000/account/getjson/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342' is therefore not allowed access.
本人的ajax代码如下
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
2. 解决方法
将上面的dataType: 'JSON'
替换为dataType: 'JSONP'
即可。
OK, Enjoy it!!!
评论列表