I try to access this URL: http://www.wienerlinien.at/ogd_routing/XML_TRIP_REQUEST2?locationServerActive=1&type_origin=coord&name_origin=16.347026:48.205452:WGS84&type_destination=coord&name_destination=16.353268603044167:48.19936173021695:WGS84
As you can see, opening the URL in the Browser, you get an XML-File. You'll also get an XML-File when opening the URL with Python:
response = requests.request('GET', 'http://www.wienerlinien.at/ogd_routing/XML_TRIP_REQUEST2?locationServerActive=1&type_origin=coord&name_origin=16.347026:48.205452:WGS84&type_destination=coord&name_destination=16.353268603044167:48.19936173021695:WGS84')
However, trying to open the same URL with jQuery, will trigger a cross origin error, specifically this one:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://www.wienerlinien.at/ogd_routing/XML_TRIP_REQUEST2?locationServerActive=1&type_origin=coord&name_origin=16.347026:48.205452:WGS84&type_destination=coord&name_destination=16.353268603044167:48.19936173021695:WGS84. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
var url = 'http://www.wienerlinien.at/ogd_routing/XML_TRIP_REQUEST2?locationServerActive=1&type_origin=coord&name_origin=16.347026:48.205452:WGS84&type_destination=coord&name_destination=16.353268603044167:48.19936173021695:WGS84'
$.get(url, function(data){
document.write(data)
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
I already tried the latest Versions of jQuery 1, 2 and 3 (hosted by Google) and i tried running the code locally and on the server. Always the same error.
How can I send this missing header that the browser itself when opening the URL is sending and which Python is obviously sending.
There is no way I can change any config on the server (wienerlinien.at) end.
This didn't work either (mainly because the repsonse is XML): jQuery ajax request being block because Cross-Origin