您的位置:首页 > 产品设计 > UI/UE

ajax跨域请求:No 'Access-Control-Allow-Origin' header is present on the requested resource

2016-12-13 12:46 951 查看
ajax跨域请求报错解决办法
		<script type="text/javascript">$(document).ready(function () {$.ajax({type : "POST",url : "http://127.0.0.1:9999/app/getToken.ya",success : function(data) {var token = eval(data).rows[0];window.location.href="http://10.6.2.26:8080/BOE/OpenDocument/opendoc/openDocument.jsp?token="+token;}});})</script>
报错:[Web浏览器] "XMLHttpRequest cannot load http://127.0.0.1:9999/app/getToken.ya. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8020' is therefore not allowed access."/HelloHBuilder/index.html (0)原因是ajax跨域请求被服务器端拒绝。只需要在服务器端加入:response.setHeader("Access-Control-Allow-Origin", "*");
即可完美解决,至于安全性问题,后期再说。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐