I'm receiving a DOM Error: DOM Exception 8 when I try to execute a very simple piece of code. Ive done similar executions a million times and I'm very confused what the problem is.
My Code:
$.post('/dataHandlers/return_stats.php', function(data) {
$('#u').html(data['username']);
var health = data['health'];
$('#health_display').html(health);
$('#energy_display').html(data['energy']);
$('#money_display').html(data['money']);
$('#intelligence_display').html(data['intelligence']);
$('#strength_display').html(data['strength']);
$('#sidebar').find('#level_display').html(data['level']);
}, 'json');
HTML:
<div id='sidebar'>
<div id ="health_display" class="stats_right"></div>
</div>
If I try and .html something that isn't a variable, it works. Whenever I .html any variable whatsoever, I get that error.
Anyone know what this is about? Thanks in advance.
Be sure you're passing a string to
html()
; if, for example, those are arrays, you can get DOM errors like that.ie,
jQuery("a").html([1,2])
throws the same error; you likely have a type problem.I wouldn't be surprised if it they're arrays; if you
alert([1,2])
, it just alerts1,2
, so everything would appear normal.