Here is my problem: I am trying to use a web t-shirt designer that uses an online t-shirt site API. The issue should have nothing to do with the application but it helps me describing the system. This designer is coded in javascript, it makes requests to a php proxy which calls the t-shirt site APIs. I uploaded the proxy and the html with the script on a webserver and everything works as it should.
Unfortunately, I need to load the html from a different domain. At first, this would rise a same-origin error. I fixed it by adding to the php proxy a
header("Access-Control-Allow-Origin: *");
However, now a new error arises from the following code
this.getShop = function (shopId) {
var shop = null;
$.ajax({
type: "GET",
async: false,
cache: true,
url: this.createUrl(this.baseHttpUrl + "/shops/" + shopId),
dataType: "xml",
crossDomain: true,
success: function(data) {
shop = $(data).find("shop");
},
error:function(xhr,err,other){
alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status+"\nerror: "+err+"\nother: "+other);
alert("responseText: "+xhr.responseText);
}
});
return shop;
};
What I get from the first alert is
readyState: 4
status: 200
error: parsererror
other: Error: Invalid XML: data
Where the final "data" is some XML data, the same I get from xhr.responseText, that seems exactly what the t-shirt site is supposed to send and also seems perfectly valid... I suppose this has still something to do with the cross-domain setting. The error comes from the parseXML jQuery function which I believe is not even invoked if I run everything from the same webserver...
Edit: Here is an example of what I get as data
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<shop xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://api.spreadshirt.net" xlink:href="http://api.spreadshirt.net/api/v1/shops/xxxxxx" id="xxxxxx">
<name>example</name>
<description>example</description>
<type>CLASSIC</type>
<user xlink:href="http://api.spreadshirt.net/api/v1/users/xxxxxxx" id="xxxxxxx"/>
<country xlink:href="http://api.spreadshirt.net/api/v1/countries/6" id="6"/>
<language xlink:href="http://api.spreadshirt.net/api/v1/languages/2" id="2"/>
<currency xlink:href="http://api.spreadshirt.net/api/v1/currencies/1" id="1"/>
<address xlink:href="http://api.spreadshirt.net/api/v1/shops/420067/address"/>
<passwordRestricted>false</passwordRestricted>
<hidden>false</hidden>
<mandator id="1"/>
<shippingUseCase id="1"/>
<defaultShippingType id="1"/>
<discountSupported>false</discountSupported>
<productTypes xlink:href="http://api.spreadshirt.net/api/v1/shops/xxxxxx/productTypes"/>
<printTypes xlink:href="http://api.spreadshirt.net/api/v1/shops/xxxxxx/printTypes"/>
<fontFamilies xlink:href="http://api.spreadshirt.net/api/v1/shops/xxxxxx/fontFamilies"/>
<productTypeDepartments xlink:href="http://api.spreadshirt.net/api/v1/shops/xxxxxx/productTypeDepartments"/>
<shippingTypes xlink:href="http://api.spreadshirt.net/api/v1/shops/xxxxxx/shippingTypes"/>
<designCategories xlink:href="http://api.spreadshirt.net/api/v1/shops/xxxxxx/designCategories"/>
<designs xlink:href="http://api.spreadshirt.net/api/v1/shops/420067/designs"/>
<articleCategories xlink:href="http://api.spreadshirt.net/api/v1/shops/xxxxxx/articleCategories"/>
<articles xlink:href="http://api.spreadshirt.net/api/v1/shops/xxxxxx/articles"/>
<products xlink:href="http://api.spreadshirt.net/api/v1/shops/xxxxxx/products"/>
<applications xlink:href="http://api.spreadshirt.net/api/v1/shops/xxxxxx/applications"/>
<currencies xlink:href="http://api.spreadshirt.net/api/v1/currencies"/>
<languages xlink:href="http://api.spreadshirt.net/api/v1/languages"/>
<countries xlink:href="http://api.spreadshirt.net/api/v1/countries"/>
<baskets xlink:href="http://api.spreadshirt.net/api/v1/baskets"/>
</shop>
<!-- Hosting24 Analytics Code -->
<script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>
<!-- End Of Analytics Code -->