Some fixes that you should take into account.
-
async: false
is deprecated, no longer used, it was a terrible idea of the old one that was removed, deprecated.
- uses
$(document).ready(
instead of $('#openTickets').ready(
, because if you use it as is, jQuery will not find this element if the HTML has not been read, whereas document
is global, made available to JavaScript since the beginning of loading page
-
$.ajax
is asynchronous which means you have to use callback success
- To change content of HTML elements with jQuery, use
.html()
or .text()
, to change the value of elements that can receive value from the user uses .val()
. In the case of a heading you should use .html()
or .text()
.
So your code might look like this:
$(document).ready(function() {
$.ajax({
time: 15,
url: "/opened-tickets",
dataType: "JSON",
success: function(res) {
$('#openTickets').html(res.responseJSON);
}
});
});
Note: I do not see where you are passing data
to ajax, I assume it is not accurate.
jsFiddle: link