Json "Access-Control-Allow-Origin" problem!

Hi,

How to add multiple domains or subdomains to the “Access-Control-Allow-Origin”!?

<?

header("Access-Control-Allow-Origin: www.domain.com");

header("Access-Control-Allow-Origin: domain.com");

?>
its taking last value, so domain.com will work, but not with www !!

any idea, I googled a lot and I could not find a way !

Thanks.

Any one have experience with this can help !

its seems am the first one who using JSON in this forum ^^

You should send one header, with the different domains separated by commas.

I have tried this
<?

header(“Access-Control-Allow-Origin: http://domain.com/, http://www.domain.com/”);
?>

but for www.domain.com am still getting :
is not allowed by Access-Control-Allow-Origin.

one of the solution worked for me to check with js if domain with www or not and pass this value to the php


$(function() {
	if (document.domain == 'www.domain.com'){
		w=1;
	}else{
		w=0;
	}

    $.getJSON("http://domain1.com/json.php?callback=json_data&w="+w, null, function(json_data) {

}

but its not the right way !

@Salathe
Would please help a little more :slight_smile: