Search code examples
jquerycordovaappmobi

How to change Access-Control-Allow-Origin in AppMobi emulator


I'm trying to access file from a server:

$.get('http://server.com/methods.php?m=loadSomething', function(data) {

    console.log(data);

});

But I get error:

Origin http://localhost:58888 is not allowed by Access-Control-Allow-Origin.

Is there any way to change Access-Control settings so I can access the remote server and obtain data?

Thanks.


Solution

  • Inside the methods.php just use the header() method like

    header('Access-Control-Allow-Origin: http://localhost:58888')