You first had a No 'Access-Control-Allow-Origin' header is present on the requested resource.
error when requesting the json ressource.
Congratulations, you fixed the header of the ressource.
It wasn't clear you had control over it at first.
Now, that resource isn't outputing a json yet.
The next error you will have to manage is parsererror
.
How did I found that error?
I used the .fail()
callback.
See in CodePen
$.getJSON('https://ministerio.herokuapp.com', function(data) {
// Whatever you do here in case of success.
}).fail(function(request,error){
console.log(request);
console.log(error);
});
You expect the result to be:
{"Ambiental":"1","Descripcion":"Mayormente nublado","Fecha_Actualizacion":"2017-09-21T18:09:51-05:00","Humedad":"70%","Picoyplaca":"1 - 3 - 5 - 7 - 9","Publico":"1 - 2","TasaRM":" $ 2,913.96","Temperatura":"14°"}
But, here is what your ressource outputs at the moment:
<p> {"Ambiental":"1","Descripcion":"Mayormente nublado","Fecha_Actualizacion":"2017-09-21T18:09:51-05:00","Humedad":"70%","Picoyplaca":"1 - 3 - 5 - 7 - 9","Publico":"1 - 2","TasaRM":" $ 2,913.96","Temperatura":"14°"}
So... Get rid of that unclosed
<p>
tag first.
You should post that ressource code... As many weird things may be found there.
But I'm quite sure the next step will be to just replace those HTML entities by the real characters needed.
Then use json_encode()
to echo the result to make sure it is properly formated if the data comes from an array (I suppose that is a PHP script).