Answers.Body: <p>A browser will give that error by default when you try make an AJAX call from domain A to domain B.</p>
  
  <p>In your particular case, it looks like you're loading the control panel from <code>mydomain.com</code>, but the live preview request (which comes from how you defined your Site URL under Settings->General) has <code>www.mydomain.com</code> in it.</p>
  
  <p>Note the <code>www</code>.  A browser will treat that as an entirely separate domain.</p>
  
  <p>If that's how you want it, great.  You need to modify your public <code>.htaccess</code> file (the one that sits next to Craft's public <code>index.php</code> file to allow the other domain via <code>Access-Control-Allow-Origin</code>.</p>
  
  <p>Likely it's just a mistake though and you should correct the Site URL setting or access the control panel from the other domain.</p>
  
  <p>It's also worth <a href="https://stackoverflow.com/questions/1157255/how-to-redirect-non-www-to-www-urls-using-htaccess">forcing one or the other</a> (www redirect to non, or non redirect to www) via <code>.htaccess</code> for consistency and because search engines will treat them as one site.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-05T20:16:29.613Z
Answers.Text: Per your suggestion, I added this to my .htaccess file    ``RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
   RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
Answers.UserDisplayName: Hellyar
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-07T23:20:44.797Z
Answers.LastActivityDate: 2016-12-07T23:20:44.797Z
Answers.UserDisplayName: Brad Bell
Answers.Body: <p>Also; in case this is part of your issue - the .htaccess file is a system file (starts with a dot) and will be hidden by default in your file browser. You either need to google how to show hidden files in your operating system, or open your project in an editor such as Visual Studio Code (free, cross platform) to see it.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-08T16:53:45.913Z
Answers.LastActivityDate: 2016-12-08T16:53:45.913Z
Answers.UserDisplayName: Matt Wilcox
Body: <p>Live preview is not working.  The following error appears in Inspect Element (Safari).  It then times out and generates a whole bunch of can't load errors. but this appears to the root of those subsequent errors.</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <a href="http://www.mydomain.com/index.php?p=posts/2016/thisost" rel="nofollow noreferrer">http://www.mydomain.com/index.php?p=posts/2016/thisost</a>. Origin <a href="http://mydomain.com" rel="nofollow noreferrer">http://mydomain.com</a> is not allowed by Access-Control-Allow-Origin.</p>
  </blockquote>
  
  <p>I saw a related question that referred to the <code>.htaccess</code> file.  But I can't seem to find the<code>.htaccess</code> file. </p>
  
  <p>So, I guess this is an A and then B question.  The first (A) being the focus and B only of import if its related to the solution for A.</p>
  
  <p>I hope that makes sense.  Thanks</p>
  
Tags: <error-message><live-preview>
Title: Live Preview fails to load
ThreadText: # Live Preview fails to load
  
  (Asked by: username_0 on 2016-12-07)
  
  Live preview is not working. The following error appears in Inspect Element (Safari). It then times out and generates a whole bunch of can't load errors. but this appears to the root of those subsequent errors.
  
  > XMLHttpRequest cannot load <http://www.mydomain.com/index.php?p=posts/2016/thisost>. Origin <http://mydomain.com> is not allowed by Access-Control-Allow-Origin.
  
  I saw a related question that referred to the `.htaccess` file. But I can't seem to find the`.htaccess` file.
  
  So, I guess this is an A and then B question. The first (A) being the focus and B only of import if its related to the solution for A.
  
  I hope that makes sense. Thanks
  
  **Tags:** error-message, live-preview
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-12-07. Score: 1 | Accepted answer
  
  A browser will give that error by default when you try make an AJAX call from domain A to domain B.
  
  In your particular case, it looks like you're loading the control panel from `mydomain.com`, but the live preview request (which comes from how you defined your Site URL under Settings->General) has `www.mydomain.com` in it.
  
  Note the `www`. A browser will treat that as an entirely separate domain.
  
  If that's how you want it, great. You need to modify your public `.htaccess` file (the one that sits next to Craft's public `index.php` file to allow the other domain via `Access-Control-Allow-Origin`.
  
  Likely it's just a mistake though and you should correct the Site URL setting or access the control panel from the other domain.
  
  It's also worth [forcing one or the other](https://stackoverflow.com/questions/1157255/how-to-redirect-non-www-to-www-urls-using-htaccess) (www redirect to non, or non redirect to www) via `.htaccess` for consistency and because search engines will treat them as one site.
  
  > **Comments:**
  > **username_0**: Per your suggestion, I added this to my .htaccess file    ``RewriteCond %{HTTP_HOST} ^mydomain.com [NC]  RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]  
  
  ---
  
  ### Answer by username_2 on 2016-12-08. Score: 1
  
  Also; in case this is part of your issue - the .htaccess file is a system file (starts with a dot) and will be hidden by default in your file browser. You either need to google how to show hidden files in your operating system, or open your project in an editor such as Visual Studio Code (free, cross platform) to see it.
  
  
  ---
  
  