<i id='VIGCn'><tr id='VIGCn'><dt id='VIGCn'><q id='VIGCn'><span id='VIGCn'><b id='VIGCn'><form id='VIGCn'><ins id='VIGCn'></ins><ul id='VIGCn'></ul><sub id='VIGCn'></sub></form><legend id='VIGCn'></legend><bdo id='VIGCn'><pre id='VIGCn'><center id='VIGCn'></center></pre></bdo></b><th id='VIGCn'></th></span></q></dt></tr></i><div id='VIGCn'><tfoot id='VIGCn'></tfoot><dl id='VIGCn'><fieldset id='VIGCn'></fieldset></dl></div>
      <tfoot id='VIGCn'></tfoot>

          <bdo id='VIGCn'></bdo><ul id='VIGCn'></ul>
      1. <small id='VIGCn'></small><noframes id='VIGCn'>

        <legend id='VIGCn'><style id='VIGCn'><dir id='VIGCn'><q id='VIGCn'></q></dir></style></legend>
      2. Access-Control-Allow-Origin 不允许来源

        时间:2023-09-03
        <legend id='2qz3G'><style id='2qz3G'><dir id='2qz3G'><q id='2qz3G'></q></dir></style></legend>

            • <bdo id='2qz3G'></bdo><ul id='2qz3G'></ul>
              • <i id='2qz3G'><tr id='2qz3G'><dt id='2qz3G'><q id='2qz3G'><span id='2qz3G'><b id='2qz3G'><form id='2qz3G'><ins id='2qz3G'></ins><ul id='2qz3G'></ul><sub id='2qz3G'></sub></form><legend id='2qz3G'></legend><bdo id='2qz3G'><pre id='2qz3G'><center id='2qz3G'></center></pre></bdo></b><th id='2qz3G'></th></span></q></dt></tr></i><div id='2qz3G'><tfoot id='2qz3G'></tfoot><dl id='2qz3G'><fieldset id='2qz3G'></fieldset></dl></div>

                <small id='2qz3G'></small><noframes id='2qz3G'>

                    <tbody id='2qz3G'></tbody>
                1. <tfoot id='2qz3G'></tfoot>

                  本文介绍了Access-Control-Allow-Origin 不允许来源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在向 中的远程 PHP 服务器发出 Ajax.requestSencha Touch 2 应用程序(包装在 PhoneGap 中).

                  I'm making an Ajax.request to a remote PHP server in a Sencha Touch 2 application (wrapped in PhoneGap).

                  服务器的响应如下:

                  XMLHttpRequest 无法加载 http://nqatalog.negroesquisso.pt/login.php.Access-Control-Allow-Origin 不允许来源 http://localhost:8888.

                  XMLHttpRequest cannot load http://nqatalog.negroesquisso.pt/login.php. Origin http://localhost:8888 is not allowed by Access-Control-Allow-Origin.

                  我该如何解决这个问题?

                  How can I fix this problem?

                  推荐答案

                  前段时间我写了一篇关于这个问题的文章,跨域 AJAX.

                  I wrote an article on this issue a while back, Cross Domain AJAX.

                  如果您可以控制响应服务器,则处理此问题的最简单方法是为以下内容添加响应标头:

                  The easiest way to handle this if you have control of the responding server is to add a response header for:

                  Access-Control-Allow-Origin: *
                  

                  这将允许跨域 Ajax.在 PHP 中,您需要像这样修改响应:

                  This will allow cross-domain Ajax. In PHP, you'll want to modify the response like so:

                  <?php header('Access-Control-Allow-Origin: *'); ?>
                  

                  您只需将 Header set Access-Control-Allow-Origin * 设置放在 Apache 配置或 htaccess 文件.

                  You can just put the Header set Access-Control-Allow-Origin * setting in the Apache configuration or htaccess file.

                  应该注意的是,这会有效地禁用 CORS 保护,这很可能会使您的用户受到攻击.如果您不知道自己特别需要使用通配符,则不应使用它,而应将您的特定域列入白名单:

                  It should be noted that this effectively disables CORS protection, which very likely exposes your users to attack. If you don't know that you specifically need to use a wildcard, you should not use it, and instead you should whitelist your specific domain:

                  <?php header('Access-Control-Allow-Origin: http://example.com') ?>
                  

                  这篇关于Access-Control-Allow-Origin 不允许来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:对于从文件://URL 运行的应用程序发出的请求,“ 下一篇:如何使跨域资源共享 (CORS) 发布请求正常工作

                  相关文章

                  最新文章

                      <tfoot id='8O4eM'></tfoot>

                      <small id='8O4eM'></small><noframes id='8O4eM'>

                      <i id='8O4eM'><tr id='8O4eM'><dt id='8O4eM'><q id='8O4eM'><span id='8O4eM'><b id='8O4eM'><form id='8O4eM'><ins id='8O4eM'></ins><ul id='8O4eM'></ul><sub id='8O4eM'></sub></form><legend id='8O4eM'></legend><bdo id='8O4eM'><pre id='8O4eM'><center id='8O4eM'></center></pre></bdo></b><th id='8O4eM'></th></span></q></dt></tr></i><div id='8O4eM'><tfoot id='8O4eM'></tfoot><dl id='8O4eM'><fieldset id='8O4eM'></fieldset></dl></div>

                      • <bdo id='8O4eM'></bdo><ul id='8O4eM'></ul>
                      <legend id='8O4eM'><style id='8O4eM'><dir id='8O4eM'><q id='8O4eM'></q></dir></style></legend>