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错误的更多相关文章

  1. 解决 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 ...

  2. 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 ...

  3. ajax跨域(No 'Access-Control-Allow-Origin' header is present on the requested resource)

    问题 在某域名下使用Ajax向另一个域名下的页面请求数据,会遇到跨域问题.另一个域名必须在response中添加 Access-Control-Allow-Origin 的header,才能让前者成功 ...

  4. (转)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 ...

  5. 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 ...

  6. 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前端部署后,查询,新增都没问 ...

  7. 跨域请求错误: 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之后 ...

  8. ajax跨域处理 No 'Access-Control-Allow-Origin' header is present on the requested resource 问题

    Controller层的类上增加@CrossOrign注解,当前文件的所有接口就都可以被调用 spring注解@CrossOrigin不起作用的原因 1.是springMVC的版本要在4.2或以上版本 ...

  9. Access control allow origin 简单请求和复杂请求

    原文地址:http://blog.csdn.net/wangjun5159/article/details/49096445 错误信息: XMLHttpRequest cannot load http ...

随机推荐

  1. Serenity框架官方文档翻译3.2(多租户)

    3.2多租户 在本教程中我们将把Norhwind变成一个多租户应用程序. 这是一个维基百科的多租户软件定义: 软件多租户是指一个软件架构的一个实例软件运行在一个服务器和多个租户.租户是一组共享一个公共 ...

  2. 记Flume-NG一些注意事项(不定时更新,欢迎提供信息)

    这里只考虑flume本身的一些东西,对于JVM.HDFS.HBase等得暂不涉及.... 一.关于Source: 1.spool-source:适合静态文件,即文件本身不是动态变化的: 2.avro ...

  3. IOC和AOP的基础原理

    IoC(Inversion of Control)就是由容器控制程序之间的关系,而非传统实现中,由程序代码直接操控.这也就是所谓“控制反转”的概念所在.控制权由应用代码中转到了外部容器,控制权的转移是 ...

  4. Internet信息服务找不到

    最近我的电脑也出现了Internet信息服务找不到的情况,在网络上查了很多方法都没一个正确的,后面通过下面的方法我成功了,故此我把这个经历也分享给大家,希望能够帮到您. 控制面板里“->添加/删 ...

  5. [Effective JavaScript 笔记]第54条:将undefined看做“没有值”

    undefined值很特殊,每当js无法提供具体的值时,就会产生undefined. undefined值场景 未赋值的变量的初始值即为undefined. var x; x;//undefined ...

  6. [COJ0989]WZJ的数据结构(负十一)

    [COJ0989]WZJ的数据结构(负十一) 试题描述 给出以下定义: 1.若子序列[L,R]的极差(最大值-最小值)<=M,则子序列[L,R]为一个均匀序列. 2.均匀序列[L,R]的权值为S ...

  7. [ruby on rails] 跟我学之(6)显示指定数据

    根据<[ruby on rails] 跟我学之路由映射>,我们知道,可以访问 GET    /posts/:id(.:format) 来显示具体的对象. 1. 修改action 修改 ap ...

  8. 【Django】如何按天 小时等查询统计?

    代码: from django.db import connection from django.db.models import Sum,Count #alarm_sum_group_items = ...

  9. JAVA 中BIO,NIO,AIO的理解

    [转自]http://qindongliang.iteye.com/blog/2018539 ?????????????????????在高性能的IO体系设计中,有几个名词概念常常会使我们感到迷惑不解 ...

  10. explict关键字

    [本文链接] http://www.cnblogs.com/hellogiser/p/explict.html [分析] explicit 只对构造函数起作用,用来抑制隐式转换. Suppose yo ...