I'm getting a malformed JSON response from an AJAX $.getJSON() request. I don't understand the problem.
Here is the request code:
var myfunc = function(){
$.getJSON( "/", {"data": ""}, function( data, status ){
var values = data;
$("#temperature").html( values.temperature.toFixed(1).toString() );
$("#humidity").html( values.humidity.toFixed(0).toString() );
});
});
and here is the JSON data received (extracted via Firefox debugger):
{
"temperature": 17.799999237060547,
"humidity": 35.900001525878906,
"failed": false
}
I cannot see what is malformed here. And the code works. DOM elements id="temperature"
and id="humidity"
are updated correctly.
I got exactly the same result using $.get()
with JSON.parse()
.
Does anybody have an idea how to solve the problem?