I need to insert an API on my site that provides the weather forecast for a particular city, however, the ajax
request always returns the error in the browser console. Follow 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.
The following is 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!');
}
});
});