简体   繁体   中英

$.inArray in jquery is not working properly

This is my code

var a=[];
var chatid=[];
$.ajax({

    type:"post",
    url:"<?php echo base_url()?>index.php/systemchat/record",
    dataType:"JSON",
    success:function(data)
    {
        alert(chatid);
        for(i=0;i<data.length;i++)
        {
             if($.inArray(data[i].user_chatid,chatid) =='-1')
             {

                var xyz=data[i].user_chatid;
                    a+='<span>'+data[i].msg+'</span></br>';
             }
            //ab.push(xyz);
        chatid+=xyz;
        }
        $("#systxtarea").append(a); 
    }

It Work's fine for index 0-9 But has problem when working for index 10,11,12...and so on

使用chatid.push(xyz)代替chatid + = xyz;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM