I'm trying to send an ajax request to an API running on the localhost but I get an error
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at
http://127.0.0.1:9100/api/banks. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
The HTML page runs at: http://localhost/jqmob/
Though the same code works fine on postman so how to solve this Issue?
var form = new FormData();
form.append("lang", "en");
var settings = {
"async": true,
"crossDomain": true,
"url": "http://127.0.0.1:9100/api/banks",
"method": "POST",
"headers": {
"Cache-Control": "no-cache",
"Postman-Token": "b246c9ad-ce2d-4e39-bbef-5df0af6476e0"
},
"processData": false,
"contentType": false,
"mimeType": "multipart/form-data",
"data": form
}
$.ajax(settings).done(function (response) {
console.log(response);
});
In the HTML page on the localhost I use jQuery 1.11.3
In the API appkication in .htaccess
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>