32
Good evening, I’m trying to access a server from my local machine and I’m getting this answer:
No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://localhost' is therefore not allowed access.
But using Postman I can - these are the server requirements:
// Estes cabecalhos sao necessarios no CORS
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PUT');
My code:
$('form').submit(function(e){
e.preventDefault();
var submit = true;
if( submit )
var form = $(this).serialize();
$.ajax({
url: url,
data: form,
dataType: 'json',
success: function(data) {
console.log(data);
},
type: 'POST'
});
return false;
});
Somebody give me a light!
I don’t know the context of your application I’ve been there and what saved me was this extension Chrome: [https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi/related]. Browser extensions have fewer restrictions on making requests. At the end of the day, to make
delete
I had to make my application an extension.– DaviAragao
Davi Aragão, it worked, thank you very much, but I really wanted to understand why I could not access without this app and what this app does that can free access
– Bruno Gomes