简体   繁体   English

XMLHttpRequest无法加载[archivo]。 所请求的资源上没有“ Access-Control-Allow-Origin”标头。 起源[dominio]

[英]XMLHttpRequest cannot load [archivo]. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin [dominio]

XMLHttpRequest cannot load [archivo]. XMLHttpRequest无法加载[archivo]。 No 'Access-Control-Allow-Origin' header is present on the requested resource. 所请求的资源上没有“ Access-Control-Allow-Origin”标头。 Origin [dominio] is therefore not allowed access. 因此,不允许访问来源[dominio]。

Buenos días, este es el error que me sale al ejecutar este código: 布宜诺斯艾利斯,错误的销售,和价格:

$.ajax({
    contentType: "application/json; charset=utf-8",
    dataType : "json",
    url: urlArchivo, 
    type: "POST",
    data: { usuario: 'test'},
    crossDomain: true,
    success: function(result) {
        alert(JSON.stringify(result));
    },
    error: function(xhr,status,error) {
        alert(status);
    },
});

He tratado de resolver el problema con jsonp , pero jsonp "transforma" el metodo POST en GET, con lo que el archivo destino no me reconoce los datos que le introduzco al utilizar el método POST para recoger los datos. 他tratado去解析EL problema CON jsonp ,佩罗JSONP “TRANSFORMA”厄尔尼诺方法方法POST EN GET,骗子老阙埃尔档案馆DESTINO没有我reconoce洛杉矶DATOS阙乐introduzco人utilizar EL方法方法POST对recoger洛杉矶DATOS。 Por lo tanto tampoco me sirve ?callback=? 我是s ?callback=? dado que también "transforma" el método POST en GET. dado quetambién“ transforma” elmétodo发布消息。

Otra solución según he visto es poner en PHP (que es el lenguaje utilizado) en el servidor destino el código: 在PHP上查看语言的详细信息,在以下方面提供了服务:

header('Access-Control-Allow-Origin: *');

Pero no quiero tener que llamar para que cambien el archivo destino. Pero no quiero tener que lalamar para que cambien el archivo destino。 Por lo que me preguntaba si existe una solución que siga transmitiendo los datos con método POST y sin tener que tocar el archivo en el servidor. 您可以在任何情况下都可以保留自己的身份,并可以在事前通知自己。

Añado que efectivamente, si envío los datos a través de un formulario html, recoge bien los datos y los transmite, pero no con AJAX. Añadoque efectivamente,在sévíolos datos发行的travésde un Formulario html,在bio los datos y los scenario的recoge中识别,pero no con AJAX。

Gracias. 格拉西亚斯。 Iván Ros 伊万·罗斯

除了修改远程服务器之外,您唯一的选择是在本地服务器上具有一个代理脚本,该脚本可从远程服务器获取您的数据。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 XMLHttpRequest无法加载“…所请求的资源上没有'Access-Control-Allow-Origin'头。” — jQuery - XMLHttpRequest cannot load “ …No 'Access-Control-Allow-Origin' header is present on the requested resource.” — Jquery XMLHttpRequest无法加载。 请求的资源上不存在“Access-Control-Allow-Origin”标头。 因此不允许原点访问 - XMLHttpRequest cannot load. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin is therefore not allowed access XMLHttpRequest无法加载在请求的资源上不存在“ Access-Control-Allow-Origin”标头。 AWS S3,Retina.JS - XMLHttpRequest cannot load No 'Access-Control-Allow-Origin' header is present on the requested resource. AWS S3, Retina.JS 所请求的资源上没有“ Access-Control-Allow-Origin”标头。 - No 'Access-Control-Allow-Origin' header is present on the requested resource. XMLHttpRequest无法加载…所请求的资源上没有“ Access-Control-Allow-Origin”标头 - XMLHttpRequest cannot load…No 'Access-Control-Allow-Origin' header is present on the requested resource XMLHttpRequest无法加载数据。 请求的资源上不存在“ Access-Control-Allow-Origin”标头 - XMLHttpRequest cannot load data. No 'Access-Control-Allow-Origin' header is present on the requested resource Wampserver XMLHttpRequest无法加载所请求的资源上不存在“ Access-Control-Allow-Origin”标头 - Wampserver XMLHttpRequest cannot load No 'Access-Control-Allow-Origin' header is present on the requested resource 所请求的资源上没有“ Access-Control-Allow-Origin”标头。 因此,不允许访问原始“呼叫URL” - No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘calling URL’ is therefore not allowed access Phonegap请求的资源上没有“Access-Control-Allow-Origin”标头。 因此不允许原点'null'访问 - Phonegap No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access 请求的资源上不存在“Access-Control-Allow-Origin”标头。 Origin '...' 因此不允许访问 - No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '…' is therefore not allowed access
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM