I am trying to use the namecheap.com API to allow domain searches from my website but I am stuck at the old problem of cross-domain blocking. On the API documentation it says that I need to make a HTTP-GET request to retrieve the XML file. I’ve done this in jQuery but I get the cross-domain error message. When I changed the dataType to jsonp like below, it gets the XML file but causes an error because the browser isn’t expecting an XML file.
jQuery.ajax({
dataType: 'jsonp',
url: 'https://api.sandbox.namecheap.com/xml.response',
data: {ApiUser: 'user', ApiKey: 'keygoeshere', UserName: 'user', Command: 'namecheap.domains.check', DomainList: 'test.com, dfuhkgusvhbksbhv.com', ClientIp: '123.1.1.123'},
success: parseXml
});
Can someone please explain how I would do this and be able to fetch the XML file without any errors?
Thanks for any help
Used simplexml_load_file() function in PHP instead and this worked OK without any cross-browser issues. API works fine using this method.