Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax error - "permission denied"
    text
    copied!<p>Sorry, this looks longer than it probably is but I thought I should include all the information!</p> <p>I'm using a simple Ajax script to dynamically bring content into a &lt;div> on a page. The first request to load some new content into the div works fine, but if I've got an Ajax "back" link within the content which has just loaded, it seems to throw an error.</p> <p>Even stranger, it works on my office network, but it fails If I'm on a home or VPN network. If it fails, this error pops up in the JavaScript debugger:</p> <pre><code>Line: 12 Char: 11 Error: Permission Denied Code: 0 URL: http://www.example.com/about.php </code></pre> <p>The code really isn't that complex, it's just a slightly hacked around version of the stuff on the W3 website, but the fact that the return call is "denied" is confusing me. Would it be something within the server IIS configuration to stop scripting attacks? (Random thought?)</p> <p>Any help appreciated ;)</p> <p><strong>First - the Ajax script</strong></p> <pre><code>var myHttpRequest = false; if(window.XMLHttpRequest) myHttpRequest = new XMLHttpRequest(); else if(window.ActiveXObject) myHttpRequest = new ActiveXObject("Microsoft.XMLHTTP"); function loadContent(source, content) { if(myHttpRequest) { var data = document.getElementById(content); myHttpRequest.open("GET",source); data.innerHTML = '&lt;div class=\"loading_image\"&gt;&lt;img src=\"images/loading.gif\" width=\"54px\" height=\"55px\" alt="loading" /&gt;&lt;/div&gt;'; myHttpRequest.onreadystatechange = function() { if(myHttpRequest.readyState==4) data.innerHTML = myHttpRequest.responseText; $('#col2_2_content').supersleight(); } myHttpRequest.send(null); } } </code></pre> <p>Then this is a truncated example of the page which calls the Ajax content and has the col2_2_content Div where everything gets inserted. The file <code>ajax.js</code> is referenced in the head section.</p> <pre><code>&lt;div id="col2_2_content"&gt; &lt;div class="mugshot_container"&gt; &lt;img src="images/mugshot_dh.jpg" onClick="loadContent('about/dh.php?ajax=yes', 'col2_2_content');"/&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>And this is the code from <code>about/dh.php</code> which is inserted via Ajax, along with the PHP formatting to decide what should be returned. (It's designed to be called directly too - in which case it gets a header/footer wrapped around).</p> <pre><code>&lt;?php $home_url = "http://www.example.com/url/"; $content = " &lt;p&gt;Some Text&lt;/p&gt; &lt;p&gt;&lt;a onClick=\"loadContent('$home_url/about/about-main.php?ajax=yes', 'col2_2_content');\"&gt;Back&lt;/a&gt;&lt;/p&gt; "; if (isset($_REQUEST['ajax']) ) { echo $content; } else { include_once 'about-header.php'; echo $content; include_once 'about-footer.php'; } ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload