So I've read all the other posts such as
but neither solution works for me.
So I have the following JavaScript code
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "react.php?do=getnotify&rand=" + Math.random(), true);
xhttp.setRequestHeader("Access-Control-Allow-Origin", "http://mydomainname.net");
xhttp.send();
Still I get the error
(index):1 Failed to load http://mydomainname.net/react.php?do=getnotify&rand=0.10280796901744726: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://mydomainname.net' is therefore not allowed access.
This only occurs when the user visits the website by going to mydomainname.net
If the user visits the site by going to www.mydomainname.net then the Ajax request works fine - no issues.
So what gives???