ajax请求node.js接口时出现 No 'Access-Control-Allow-Origin' header is present on the requested resource错误
ajax请求node.js接口出现了如下的错误:
XMLHttpRequest cannot load http://xxx.xxx.xx.xx:8888/getTem?cityId=110105&date=2015-03-04. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
百度了一下,原来是缺少Access-Control-Allow-Origin属性,那么在node.js输出时把Access-Control-Allow-Origin属性加上就好了,如下
response.writeHead(200, {'Content-Type': 'text/json;charset=utf-8','Access-Control-Allow-Origin':'*'});
谷歌查了一下,原来Access-Control-Allow-Origin来限制请求域名的。 点我查看该属性的解释
ajax请求node.js接口时出现 No 'Access-Control-Allow-Origin' header is present on the requested resource错误的更多相关文章
- 解决 js ajax跨域访问报“No 'Access-Control-Allow-Origin' header is present on the requested resource.”错误
参考页面:https://blog.csdn.net/idomyway/article/details/79572973 如果请求的是PHP页面: header("Access-Contro ...
- java、ajax 跨域请求解决方案('Access-Control-Allow-Origin' header is present on the requested resource. Origin '请求源' is therefore not allowed access.)
1.情景展示 ajax调取java服务器请求报错 报错信息如下: 'Access-Control-Allow-Origin' header is present on the requested ...
- ajax跨域(No 'Access-Control-Allow-Origin' header is present on the requested resource)
问题 在某域名下使用Ajax向另一个域名下的页面请求数据,会遇到跨域问题.另一个域名必须在response中添加 Access-Control-Allow-Origin 的header,才能让前者成功 ...
- (转)AJax跨域:No 'Access-Control-Allow-Origin' header is present on the requested resource
在本地用ajax跨域访问请求时报错: No 'Access-Control-Allow-Origin' header is present on the requested resource. Ori ...
- js跨域访问,No 'Access-Control-Allow-Origin' header is present on the requested resource
js跨域访问提示错误:XMLHttpRequest cannot load http://...... No 'Access-Control-Allow-Origin' header is prese ...
- ABP PUT、DELETE请求错误405.0 - Method Not Allowed 因为使用了无效方法(HTTP 谓词) 引发客户端错误 No 'Access-Control-Allow-Origin' header is present on the requested resource
先请检查是否是跨域配置问题,请参考博客:http://www.cnblogs.com/donaldtdz/p/7882225.html 一.问题描述 ABP angular前端部署后,查询,新增都没问 ...
- 跨域请求错误: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource
今天在学习Angular 的HttpInterceptor 拦截器时,发现添加了新的headers键值之后总是报跨域错误.后台使用的是asp.net core. 检查发现,在添加了新的header之后 ...
- ajax跨域处理 No 'Access-Control-Allow-Origin' header is present on the requested resource 问题
Controller层的类上增加@CrossOrign注解,当前文件的所有接口就都可以被调用 spring注解@CrossOrigin不起作用的原因 1.是springMVC的版本要在4.2或以上版本 ...
- Access control allow origin 简单请求和复杂请求
原文地址:http://blog.csdn.net/wangjun5159/article/details/49096445 错误信息: XMLHttpRequest cannot load http ...
随机推荐
- Ubuntu如何安装secureCRT
以前在ubuntu上安装过secureCRT,是自己按照网上的教程安装的. 电脑重装了系统之后,想在电脑上安装一个,又得去网上搜,安装完后,自己总结了一下. 1,下载secureCRT包 根据自己电脑 ...
- 学习Linux下的IP地址地理位置信息显示工具nali
首先详细教程已经有前辈做了详细的安装和使用介绍,本人只是参照学习和记录下自己的实际操做. 本文参考档:http://www.cnblogs.com/mchina/archive/2012/12/24/ ...
- HDOJ 1848 Fibonacci again and again
Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- 在CentOS 7 上搭建LAMP
导读 要求:httpd的动态和静态资源分为两台主机提供,mysql也用单独一台主机.httpd服务提供虚拟主机,一个虚拟主机用于提供phpMyAdmin:另一个虚拟主机用于提供wordpress.安装 ...
- CoreLoation
- (CLLocationManager *)locationManager { if (!_locationManager) { _locationManager = [[CLLocationMan ...
- Stanford机器学习---第二讲. 多变量线性回归 Linear Regression with multiple variable
原文:http://blog.csdn.net/abcjennifer/article/details/7700772 本栏目(Machine learning)包括单参数的线性回归.多参数的线性回归 ...
- POJ 1308&&HDU 1272 并查集判断图
HDU 1272 I - 小希的迷宫 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64 ...
- centOS设置zookeeper开机自动启动
在/etc/rc.local文件中追加: # java_homeexport JAVA_HOME=/opt/java/jdk1.7.0_75# zookeeper/home/cent2014/zook ...
- 63.如何对单链表进行快排?和数组快排的分析与对比[quicksort of array and linked list]
[本文链接] http://www.cnblogs.com/hellogiser/p/quick-sort-of-array-and-linked-list.html [题目] 单链表的特点是:单向. ...
- Sybase IQ如何将大文件数据迅速加载到数据库
试想一下,如果一个文件5G.10G甚至更大.如何将它迅速地加载到数据库指定的表呢?我们看看Sybase IQ是如何迅速地将表的数据加载到数据库的. 数据文件格式: 1440,2011-01-09 00 ...