简体   繁体   English

XMLHttpRequest 无法加载。 Access-Control-Allow-Origin 不允许 Origin http://localhost:63342

[英]XMLHttpRequest cannot load . Origin http://localhost:63342 is not allowed by Access-Control-Allow-Origin

$http({
    method: "POST",
    url: 'http://192.168.3.140:8081/SamplengcordovaApp/Savedata.php',
    data: resdata,
    dataType: "json"
  })
       .success(function (data, status, headers, config) {
                debugger;
                alert(data);
        })
        .error(function (data, status, headers, config) {
               alert(status);
        });

getting the success but not saved in database.please provide the supported code for me.获得成功但未保存在数据库中。请为我提供支持的代码。

This is basically a Cross-origin resource sharing (CORS) problem.这基本上是一个跨域资源共享(CORS)问题。

You are making an ajax request from a page of different domain.您正在从不同域的页面发出 ajax 请求。 which is not allowed.这是不允许的。

To allow it you will have to append Access-Control-Allow-Origin in the response header of the server page by adding this on the top of the server page要允许它,您必须将Access-Control-Allow-Origin添加到服务器页面的响应标头中,方法是将其添加到服务器页面的顶部

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

Note: the '*' at the end means it will accept any request from any website, for added security you could do this注意:末尾的“*”表示它将接受来自任何网站的任何请求,为了增加安全性,您可以这样做

header('Access-Control-Allow-Origin: http://yourwebsite.com');

暂无
暂无

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

相关问题 Access-Control-Allow-Origin 不允许 XMLHttpRequest - XMLHttpRequest is not allowed by Access-Control-Allow-Origin qooxdoo:Access-Control-Allow-Origin不允许XMLHttpRequest Origin null - qooxdoo : XMLHttpRequest Origin null is not allowed by Access-Control-Allow-Origin XMLHttpRequest 无法加载 url 并且我的域不允许 Access-Control-Allow-Origin - XMLHttpRequest cannot load url and my domain not allowed by Access-Control-Allow-Origin jQuery表单插件:XMLHttpRequest无法加载http:// www…否'Access-Control-Allow-Origin' - jQuery Form Plugin : XMLHttpRequest cannot load http://www…No 'Access-Control-Allow-Origin' Access-Control-Allow-Origin不允许AngularJS Origin http:// localhost:8080 - AngularJS Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin 所请求的资源上没有“ Access-Control-Allow-Origin”标头。 因此,不允许访问来源“ http:// localhost:4200” - No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access XMLHttpRequest无法加载数据。 请求的资源上不存在“ Access-Control-Allow-Origin”标头 - XMLHttpRequest cannot load data. No 'Access-Control-Allow-Origin' header is present on the requested resource 跨域 XMLHttpRequest、Access-Control-Allow-Origin 标头和 $_SERVER['HTTP_ORIGIN'] - Cross-domain XMLHttpRequest, Access-Control-Allow-Origin header and $_SERVER['HTTP_ORIGIN'] Access-Control-Allow-Origin不允许使用Chrome Origin null - Chrome Origin null is not allowed by Access-Control-Allow-Origin php原点是Access-Control-Allow-Origin所不允许的 - php Origin is not allowed by Access-Control-Allow-Origin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM