"对象对象"在Javascript中不再可用

时间:2014-03-21 13:16:35

标签: javascript php error-handling

我得到的输出看起来像这样

" object对象不再可用,已从作业#257"

中删除

使用以下代码

if(typeof find_staff.staff != 'undefined') {
    var staff = find_staff.staff;
    staff = $.extend({}, staff.preferences, staff.staff); 

    if(typeof(staff[staff_id]) != 'undefined') {
        loop_continue = true;
    }
    else {
        $('#' + i).html('<p>' + staff + ' is no longer available and has been removed from assignment #' + booking_id + '</p>');

        // Break from loop
        loop_continue = false; 
    }
}
else {
    $('#' + i).html('<p>' + staff + ' is no longer available and has been removed from #' + v.booking_id + '</p>');

    // Break from loop
    loop_continue = false; 
}

1 个答案:

答案 0 :(得分:3)

很明显staff是一个对象,因为$ .extend返回

var staff = find_staff.staff;
staff = $.extend({}, staff.preferences, staff.staff); 

恰好,对象的字符串表示形式为[Object, object] 因此,'<p>' + staff + ' is no lo...使用字符串对对象进行汇总,有效地执行staff.toString(),从而为您提供[Object, object]