I tried to call the eBay FindProducts API using AJAX ( postrequest), but got stuck with the following error:
XMLHttpRequest cannot load http://open.api.ebay.com/shopping?callname=FindProducts . The origin of http://localhost.com/test.php is not allowed by Access-Control-Allow-Origin.
My code is:
$.ajax
({
type: "POST",
url: 'http://open.api.ebay.com/shopping?callname=FindProducts',
dataType: ($.browser.msie) ? "text" : "xml",
contentType: 'application/x-javascript',
crossDomain : true,
data: {
'X-EBAY-API-APP-ID' : 'ebayAppId',
'X-EBAY-API-VERSION': '771',
'X-EBAY-API-SITEID': '0',
'X-EBAY-API-REQUEST-ENCODING': 'NV',
'X-EBAY-API-RESPONSE-ENCODING': 'json',
'QueryKeywords' : '753759971632',
'MaxEntries' : '3'
},
success: function (result) {
alert('success');
alert(result);
},
error: function (data) {
alert((data));
}
})
How can I get through this error.
I tried to install dataType : jsonp(I know that XML is being extracted, but to work around the error I installed it in jsonP). It works, but jQuery was unable to parse the XML, as the json response was expected.
source
share