Cross-Domain XML Querying
<p>I have two servers in my organization. One of which is read-only to me (Server A) and the other hosts our knowledge base (Server B). There is an XML file on <strong>Server A</strong> which is refreshed at an unknown interval. This file contains information on the status of various items. I want to be able to display those statuses on <strong>Server B</strong>.</p>

<p>As a beginner, I'm having trouble getting around the same-origin policy since I do not have access to <strong>Server A</strong>.</p>

<p>Right now I'm trying to use a simple python script <em>xmlpull.py</em>:</p>

<pre><code>import urllib2

response = urllib2.urlopen('http://192.168.255.255/connections')
html = response.read()
</code></pre>

<p>The script works great on its own, but the issue is when I try to load it using JQuery (<em>xmlpull.html</em>):</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt;&lt;/script&gt;
&lt;script&gt;
$(document).ready(function(){
    $.ajax({url: "xmlpull.py", success: function(result){
        $("#2").html(result);
    }});
});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="2"&gt;Change Me Please&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>FF just gives me syntax errors for both <em>xmlpull.html</em> and <em>xmlpull.py</em> files at <code>:1:1</code>.</p>

<ol>
<li>What am I doing wrong?</li>
<li>If this isn't the best way to approach this problem, then feel free to suggest a better way.</li>
</ol>

<p>Thanks in advance!</p>

<p>You have 3 Options options:</p>

<ul>
<li><p>First: is to allow Server B to access Server A. If you are using apache server you can do this by add this code the apache configuration file and restart apache</p>

<p>SetEnvIf Origin
"http(s)?://(www.)?(WRITE_IP_OF_SERVER_B_HERE)$"
AccessControlAllowOrigin=$0 Header add Access-Control-Allow-Origin
%{AccessControlAllowOrigin}e env=AccessControlAllowOrigin Header set
Access-Control-Allow-Headers "Content-Type, Accept, Authorization,
X-Requested-With"</p></li>
</ul>

<p>This way you can call Server A from Server B direct from the js and no need to the to create python file.<br></p>

<ul>
<li>Second using the python file:<br>to call python file from ajax, the python file should be accessable using apache or other server and to do this you have two options. mode wsgi or mod python and both will require apache configuration and code change more than the code size</li>
<li>Third way if to use PHP for this task by creating a php file and add it to apache public folder ( www ) you can call it direct without apache 
configuration.<br>file content will be:</li>
</ul>

<p>&lt;?= file_get_contents("<a href="http://192.168.255.255/connections" rel="nofollow">http://192.168.255.255/connections</a>"); ?></p>

jquery python ajax xml same-origin-policy