Question

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.

Was it helpful?

Solution

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

header('Access-Control-Allow-Origin: http://localhost:58888')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top