I try to reach out to the IKEA Api to access the availability checker. If I want to ajax the file it wont return anything and the .fail function is called.
$('#availability').submit(function (event) {
let productNumber = $('#productId').val();
if (testString(productNumber, '^[0-9]{3}\.[0-9]{3}\.[0-9]{2}$')) {
productNumber = productNumber.replace(/\./g, '');
let target = 'http://ikea.com/de/de/iows/catalog/availability/' + productNumber;
$.ajax({
url: target,
cache: false,
dataType: 'xml'
})
.done(function (data) {
console.log('succes');
})
.fail(function (x) {
console.log(x);
});
}
event.preventDefault();
});
You don't see any result because your request is being blocked (here is the error that I see in the console):
XMLHttpRequest for http://ikea.com/de/de/iows/catalog/availability/00122822/ required Cross Origin Resource Sharing (CORS).
Redirect was blocked for CORS request
There are several links related to CORS error in StackOverflow. Apparently, this is a security setting in your browser and it is unsafe to turn it off.
I found this link that suggests a workaround: https://www.nczonline.net/blog/2010/05/25/cross-domain-ajax-with-cross-origin-resource-sharing/