I attempt to make an AJAX HTTP POST to an API another developer built. I use JQuery for that, the API is in PHP. However, I receive the following error in the console:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource
My HTML:
<form>
<input id="target" type="text" value="Field 1">
</form>
My Javascript/JQuery:
$("#target").on("click", checkemail);
function checkemail(){
$.ajax({
type: 'POST',
url: 'https://test.api.planitcommander.nl/funnel_webhooks/emailExists',
data: JSON.stringify({"email": "rj@xxxx.nl"}),
contentType: "application/json",
dataType: 'json'
})
.fail (function(data){
console.log(data);
})
}
Is there a mistake in my JQuery code, or should I ask the API developer for a solution?
Seems like the latter going from: Javascript CORS - No 'Access-Control-Allow-Origin' header is present