A JavaScript object is used to store error messages. Works great if there are errors, but if no errors (object is blank) the code fails. So, I added the jQuery $.isEmptyObject()
test -- and now it fails if there is content.
Why does this code fail when trying to read the size of the object?
HTML:
<div>If visible, code not work</div>
jQuery:
var tmp;
var objErr = new Object();
objErr['test'] = 'bob';
if ($.isEmptyObject(objErr) ){
$('div').hide();
}else{
tmp = Object.size(objErr); //<=== fails here
$('div').hide(); //if not work, js is broken
}
if (tmp > 1){
$('div').hide();
alert(tmp);
}else{
$('div').hide();
}