简体   繁体   English

CORS原始请求在android应用程序中被阻止

[英]CORS Origin Request Blocked in android application

We have developed android application in IONIC with anguler js. 我们已经使用anguler js在IONIC中开发了android应用程序。

We are testing through browser but in is giving error in console. 我们正在通过浏览器进行测试,但是在控制台中给出了错误。

cross Origin request blocked: the same origin policy disallows reading the remote resource at http://example/abc/service.php (Reason: CORS Request did not succeed) 跨源请求被阻止:相同的源策略禁止读取http://example/abc/service.php上的远程资源(原因:CORS请求未成功)

cross Origin request blocked: the same origin policy disallows reading the remote resource at http://example/abc/service.php (Reason: Multiple CORS request did not succeed) 跨源请求被阻止:相同的源策略禁止读取http://example/abc/service.php上的远程资源(原因:多个CORS请求未成功)

<?php
   header('Access-Control-Allow-Origin: *'); 
header('Access-Control-Allow-Headers: Content-Type');

error_reporting(E_ALL);



 ?>

Tried with Access-Control-Allow-Origin:null and Access-Control-Allow-Origin: example.com 尝试使用Access-Control-Allow-Origin:null和Access-Control-Allow-Origin:example.com

Still not working 还是行不通

We are using anguler js in android application development with IONIC Framework 我们正在使用IONIC Framework在android应用程序开发中使用anguler js

Help! 救命! If you know ! 如果你知道的话 !

"jsonp" You can have a try. “ jsonp”您可以尝试。

   <script type="text/javascript">
 jQuery(document).ready(function(){ 
    $.ajax({
         type: "get",
         async: false,
         url: "http://example/abc/service.php ",
         dataType: "jsonp",
         jsonp: "callback",
         jsonpCallback:"flightHandler",
         success: function(json){
             alert(json.price);
         },
         error: function(){
             alert('fail');
         }
     });
 });
 </script>

您可以使用cordova-plugin-whitelist

<access origin="http://example/" /> //specify your domain

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

相关问题 跨域请求被 cors 阻止 - cross origin request blocked by cors 跨域请求被阻止 - 这可以通过启用CORS来修复 - Cross-Origin Request Blocked - This can be fixed by enabling CORS CORS 阻止原点 - 原点和允许原点相同 - CORS blocked origin - Origin and allowed origin are the same 跨域请求被阻止:CORS header 'Access-Control-Allow-Origin' 缺失 - Cross-Origin Request Blocked: CORS header ‘Access-Control-Allow-Origin’ missing ajax发布请求-跨域读取阻止(CORB)阻止了跨源响应CORS - ajax post request - cross-Origin Read Blocking (CORB) blocked cross-origin response CORS 跨域请求被阻止:(原因:缺少CORS标头“ Access-Control-Allow-Origin”) - Cross-Origin Request Blocked: (Reason: CORS header 'Access-Control-Allow-Origin' missing) CORS – 跨域请求被阻止 – &#39;Access-Control-Allow-Origin&#39; 标头包含无效值 - CORS – Cross Origin Request Blocked – The 'Access-Control-Allow-Origin' header contains invalid value API 请求被 CORS 阻止 - API request blocked by CORS 交叉原始请求被阻止 - Cross origin request blocked CORS 问题 - CORS 策略阻止了从 *** 获取 *** 的访问权限:无“访问控制允许来源” - 对 Z035489FF8D092741943E4A83241F5AF9 的请求 - CORS problem - Access to fetch at *** from origin *** has been blocked by CORS policy: No 'Access-Control-Allow-Origin' - PUT request to Firebase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM