title: JavaScript runtime error: Permission denied
body: <p>I have an MVC4 project, and an error that happens usually after the second time of 'SetInterval'. The first time the opening window is fine, but after it I receive an error on this line :</p>
  
  <blockquote>
    <p>$(w.document.body).html(data.toString());</p>
  </blockquote>
  
  <p>the error is:</p>
  
  <blockquote>
    <p>JavaScript runtime error: Permission denied</p>
  </blockquote>
  
  <p>Here is the code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  &lt;head&gt;
      &lt;meta name="viewport" content="width=device-width" /&gt;
      &lt;script src="../../Scripts/jquery-1.7.1.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;title&gt;Home&lt;/title&gt;
       &lt;script type="text/javascript"&gt;
           alert('1');
           $(document).ready(setInterval(function () {
               
               $.ajax({
                   url: '/api/data/',
                   data: { pcName: '' },
                   type: 'GET',
                   success: function (CLID) {
                       //
                       
                       if (CLID != null) {
  
                           $.ajax({
  
                               data: { line: CLID },
                               type: 'POST',
                               datatype: 'html',
                               url: '/Home/PopPage/',
                               success: function (data) {
                                   var w = window.open("about:blank", 'PopPage', 'height=300,width=200');
                                   $(w.document.body).html(data.toString());
                               }
                           });                        
                       }
                   }
               });
  
           }, 2000));
           
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body style=" height: 200px;width: 700px;"&gt;
      &lt;div&gt;
          
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>UPDATE: A Data controller</p>
  
  <pre><code>        // GET api/data/5
      public string Get(string pcName)
      {
          string Line="";
          SetLogFiles();
          Logger.Write("Data");
          List&lt;Campaign&gt; CampaignList = new List&lt;Campaign&gt;();
  
          Logger.Write("Before PcName");
          //  do db logic
          try
          {
              pcName = System.Environment.MachineName;
              Logger.Write("PC Name: "+pcName);
  
              Line = DBAccess.GetDataLinesByKey(pcName);
  
  
          }
          catch (Exception ex)
          {
              Logger.WriteError(ex);
          }
  
          return Line;
      }
  </code></pre>