I'm trying to make a POST
request in JSON
to an external domain but I can't access the server's files to modify them.
When I do this request, I get the following error
XMLHttpRequest cannot load https://external.com. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.ownedwebsite.com' is therefore not allowed access.
Where is the problem?
Here's the code I'm using:
$(document).ready(function(){
$("#submit").on('click', function(){
event.preventDefault();
$.ajax({
url: 'https://external.com',
type : "POST",
crossDomain: true,
dataType : 'json',
beforeSend: function (request)
{
//request.setRequestHeader("name", "value");
},
data : $("#formCart").serialize(),
success : function(result) {
alert('POST done.');
},
error: function(xhr, resp, text) {
alert('POST failed.');
}
})
});
});
What could I do? All I need to do is to send this POST form data in JSON format.