IE因类型转换而失败$ .inArray()

时间:2014-02-16 10:44:45

标签: php jquery

此代码适用于firefox& chrome,但Internet Explorer 10失败(始终返回-1):

if (room.room.isGroupChat == 1 && $.inArray(WCF.User.userID, room.users) == -1) {
    console.log(WCF.User.userID); // returns 297
    console.log(room.users); // returns 297,452,637,483,9,14,71,372 
    console.log($.inArray(WCF.User.userID, room.users)); // returns -1
}

room.users通过AJAX传递:

$users = array();
if ($message->type == CChat::MESSAGE_KICKED) {
    $roomUsers = $room->getUsers();

    foreach ($roomUsers as $user) {
        $users[] = $user->userID;
    }
}

但如果我输入强制转换(int) $user->userID,它在IE中运行正常。 有没有机会让IE在没有类型转换的情况下工作?

0 个答案:

没有答案