[英]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.