5
I’m trying to access a URL
in AJAX
but it’s making the following mistake:
Xmlhttprequest cannot load http://receitaws.com.br/v1/cnpj/MEUCNPJ. In the 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://localhost:50562' is therefore not allowed access. Create? Length=0:201 Error: [Object Object]
mine 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
OF 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"
}
I think it can help you here. http://answall.com/questions/47189/consumer-webservice-de-um-link-external
– Marconi
gave the same error @Marconi
– Furlan
Tried the $..Getjson and gave the same thing?
– Marconi
yes, same bug @Marconi
– Furlan
What is the return you get when you open the link on the page? You could edit your question with it, even if it is given fictitious.
– Marconi
Probably the destination, being hosted on a website and you are running the script internally with localhost, can not authenticate to get this information, the two pages would be hosted on the same domain?
– jefissu
Your Webservice was developed in what technology? You have access to its code?
– Pedro Camara Junior
am using . Net MVC @Pedrocamarajunior
– Furlan
I don’t have access to the same code @Pedrocamarajunior
– Furlan