We have developed android application in IONIC with anguler js.
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)
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)
<?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
Still not working
We are using anguler js in android application development with IONIC Framework
Help! If you know !
"jsonp" You can have a try.
<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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.