1
I need to insert an API on my site that brings the weather forecast for a certain city, however, the request ajax
always returns the error in the browser console. Below:
XMLHttpRequest cannot load http://developers.agenciaideias.com.br/tempo/json/são paulo-SP. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:50745' is therefore not allowed access.
Follow the requisition code:
$(document).ready(function () {
$.ajax({
url: 'http://developers.agenciaideias.com.br/tempo/json/são paulo-SP',
type: 'GET',
dataType: 'json',
success: function(dados) {
alert("Success");
},
error: function() {
alert('Failed!');
}
});
});