I'm trying to make a cross domain ajax request i have set the PHP headers on the receiving end and set the jQuery AJAX request but for some reason it works then you refresh the page and it fires a cors origin error with a response code of 503 which from my research its caused by CORS.
I have followed some instructions from here How do I send a cross-domain POST request via JavaScript?
Headers for api.mydomain.co.uk
header('Access-Control-Allow-Origin: https://mydomain.co.uk');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
jQuery for mydomin.co.uk
$.ajax({
type: 'POST',
url: "//api.mydomain.co.uk/application/mp/basket",
crossDomain: true,
xhrFields:{withCredentials: true},
data: {Route: "ItemCount"},
success: function(data) {
$('.count').text(data);
}
});