Answer the question
In order to leave comments, you need to log in
How to send xml using Ajax request to another domain?
$.ajax({
type: 'POST',
url: "https://domain.com",
crossDomain: true,
data: xml,
dataType: 'xml',
success: function(responseData, textStatus, jqXHR)
{
console.log(responseData);
},
error: function(responseData, textStatus, errorThrown)
{
console.log(responseData, textStatus, errorThrown);
}
});
XMLHttpRequest cannot load https://domain.com No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://demo.ua' is therefore not allowed access.
How to send such a request?
Answer the question
In order to leave comments, you need to log in
If the server is not yours, then there is little you can do. You can use reverse proxy to proxy your requests. For example Apache .
And if yours, use CORS . Add the "Access-Control-Allow-Origin" header and it will work.
However, if you need to send POST requests, then make sure the requests do not contain additional headers (eg "X-Requested-With: XMLHttpRequest"). Because in the presence of additional headers, with an unsafe method, a HEAD request is additionally made to obtain the "Access-Control-Allow-Headers" header.
In an amicable way, for cross-domain requests, you need to use JSONP.
There are other options, for example read here javascript.ru/ajax/cross-domain-scripting
If the server is yours, just set the correct Access-Control-Allow-Origin header. If the server is not yours - make a browser extension, they can send requests to another domain *.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question