I\'m currently trying to display a list of values that get updated every 5 seconds to a sqlite database.
I can manage to convert the results to a JSON format by usin
Your AJAX call should auto-detect a JSON response, but it won't hurt to explicitly tell jQuery about it:
$.ajax({
type: "GET",
url: $SCRIPT_ROOT + "_status",
dataType: 'json',
success: function(data) {
$('#Result').text(data);
}
);
The contentType
parameter is only used for a POST request, telling the server what type of data you sent.
The data
object contains whatever your Flask jsonify()
response returned; in this case it'll be a JavaScript Object with the BoilerRoom
, etc. keys.
Since you are loading JSON over a GET request, you may as well use the jQuery.getJSON() method here:
$.getJSON(
$SCRIPT_ROOT + "_status",
function(data) {
$('#Result').text(data);
}
);
This does exactly the same as the $.ajax()
call but you get to omit the type
and dataType
parameters, and the url
and success
parameters are just positional elements.