I have a problem updating the content of a section when I try to do it with .load()
jQuery.
I don't know why, but it tries to load content from the main domain instead of the subdomain I'm on.
The error I get is:
XMLHttpRequest cannot load https://www.myweb.com/master/ . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://test.myweb.com' is therefore not allowed access.
The line I use is:
$('.refresh').load('contact.php?id=' + contactId + ' .refresh');
Your problem is due to the fact that " https://www.myweb.com/master/ " has a different subdomain than " https://test.myweb.com " even though the domain is the same, the 'test' subdomain is different to 'www', if you want it to work you must add the CORS headers to your contact.php file.
Unfortunately this gives you access to any domain
Another solution would be
Finally you could modify your .htaccess file if you use apache. So that something like this remains.
EDIT: Or you can just put everything under the same domain www.mytest.com and avoid setting headers.
Try adding this tag to your
<head>
:With that tag, it should search all files from that base.