This is not an actual solution for my problem given. But it is a way to bypass the origin using PHP.
In my javascript, I've requested my PHP code using the following:
function Communication () {
this.global = new Global();
this.allowedParameters = ["Character"];
this.retrieveXMLFromRemoteServer = function (section, keyId, vCode) {
if (this.global.arrayContainsValue(section, this.allowedParameters)) {
$.get(this.formatCommunicationURL(section, keyId, vCode), function(data) {
alert(data);
});
}
}
this.formatCommunicationURL = function (baseUri, keyId, vCode) {
return "server/" + baseUri + ".php?keyId=" + keyId + "&vCode=" + vCode;
}
}
Whichs called for example: server/Character.php?keyId=00001&vCode=002342345234
The PHP file contains the following code:
namespace my_api;
class Character {
function retrieveCharacters ($keyId, $vCode) {
return file_get_contents("https://external_url/Characters.aspx?keyId=" . $keyId . "&vCode=" . $vCode);
}
}
$char = new Character();
echo $char->retrieveCharacters($_GET['keyId'], $_GET['vCode']);
?>
This file retrieves the data from the external URL, and then echo's the output so there is a response text JS will be able to use.
Hope this helps for some of you :)