0
I am implementing integration with a WS which searches the data on the basis of cnpj.
When consulting the WS and request a callback
, it returns me the following ERROR:
Uncaught Syntaxerror: Unexpected token :
I believe you’re misinterpreting Json.
The code I’m using is in this remap:
<html>
<head>
<title>CNPJ Webservice</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Adicionando Javascript -->
<script type="text/javascript" >
function meu_callback(conteudo) {
//Atualiza os campos com os valores.
document.getElementById('txtRazao').value=(conteudo.nome);
}
function pesquisacep(valor) {
//Nova variavel "cep" somente com d�gitos.
var cnpj = valor;
//Cria um elemento javascript.
var script = document.createElement('script');
//Sincroniza com o callback.
script.src = '//receitaws.com.br/v1/cnpj/'+ cnpj + '/?callback=meu_callback';
//Insere script no documento e carrega o conte�do.
document.body.appendChild(script);
};
</script>
</head>
<body>
<!-- Inicio do formulario -->
<form method="get" action=".">
<label>Cep:
<input name="txtCNPJ" type="text" id="txtCNPJ" value=""
onblur="pesquisacep(this.value);" /></label><br />
<label>Nome:
<input name="txtRazao" type="text" id="txtRazao" size="60" /></label><br />
</form>
</body>
</html>