Reading in JSON file generating error

0

I'm trying to do a read in JSON, and result what I want in a div but my console is returned the following error,

XMLHttpRequest cannot load

JSON file:

{"content":{"nome":"Josimara","pais":"brasil"}}

HTML

<script type="text/javascript">

    $(function() {

        $.get("arquivo/json", {  },
        function(data){
        $("#nome").html(data.nome);
        }, "json");

    });

</script>

<div id="nome"></div>

What could be the error?

    
asked by anonymous 25.09.2017 / 20:59

1 answer

1

The problem is CORS , when testing the code below, I received the following error. Failed to load https://trustedcompany.com/api/v1/company/bbbaterias.com.br?key=f157aee72a787417c20a71ac21708ee8-1b06b0bab68ccc183f78742e3bb8f852: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8081' is therefore not allowed access.

$.ajax({
	type: 'GET',
	url: 'https://trustedcompany.com/api/v1/company/bbbaterias.com.br?key=f157aee72a787417c20a71ac21708ee8-1b06b0bab68ccc183f78742e3bb8f852',
	dataType: 'json',
	cache: false,
	success: function(data){
           $('#app').html(data)
	   console.log(data)
	}
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divid="app"></div>

What does it mean that you do not have permission to access the server, I tested it with jsonp and it does not seem to work, if you do not have something about documentação , you will not have it.

    
25.09.2017 / 21:48