I'm trying to access a URL
in AJAX
but is giving the following error:
XMLHttpRequest can not load link . At the 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' link ' is therefore not allowed access. Create? Length = 0: 201 Error: [object Object]
My AJAX
:
var url = "http://receitaws.com.br/v1/cnpj/MEUCNPJ";
$.ajax({
url: url,
dataType: "json",
type: "GET",
beforeSend: function (data) {
console.log("aguarde");
},
success: function (data) {
console.log(data);
},
error: function (data) {
console.log("Erro: " + data);
}
});
JSON
FROM THE PAGE:
{
"abertura": "TESTE",
"atividade_principal": [
{
"code": "TESTE",
"text": "TESTE"
}
],
"atividades_secundarias": [
{
"code": "TESTE",
"text": "TESTE"
}
],
"bairro": "TESTE",
"cep": "TESTE",
"cnpj": "TESTE",
"complemento": "",
"data_situacao": "TESTE",
"data_situacao_especial": "********",
"efr": "*****",
"email": "TESTE",
"fantasia": "********",
"logradouro": "TESTEP",
"motivo_situacao": "",
"municipio": "TESTE",
"natureza_juridica": "TESTE",
"nome": "TESTE",
"numero": "TESTE",
"situacao": "ATIVA",
"situacao_especial": "********",
"status": "OK",
"telefone": "TESTE",
"tipo": "TESTE",
"uf": "TESTE"
}