I need to check if a number is present in an array of number that I get from PHP, and if yes render a data coming from iosocket. But for some reason this code won't work. The array return 20, 25 and the number to check is 20 f.example
<script>
var negozi_seguiti = <?php echo json_encode($negozi_seguiti); ?>;
var post = io('http://1clickfashion.com:3002');
post.on("test-channel:App\\Events\\Post", function(message){
// increase the power everytime we load test route
alert(negozi_seguiti);
if (jQuery.inArray(negozi_seguiti, message.data.negozio) == -1) {
$('#timeline').addClass("timeline");
$('#timeline').prepend(message.data.timeline);
$('#rocket').hide();
}
});
</script>
What i'm wrong?
jQuery.inArray( value, array [, fromIndex ] )you seem to be passing arguments in the wrong order===instead of==