I am working with php and ajax,I am getting ajax response( as ["463","500","505"] ) and i am trying to pass this via loop but loop is working only single time instead of three Here is my code,Where i am wrong ?
$.ajax({
type: "post",
url:'<?php echo base_url();?>Main/GetFollowingCoinUsers',
data: {coin_id:coin_id},
success: function (datan) {
//datan contaning values like - ["463","500","505"]
var str_array = datan.split(',');
var conn = new WebSocket('ws://localhost:8282');
var client = {
user_id: <?php echo $number; ?>,
recipient_id: null,
NotificationType: 'notification',
type: 'socket',
token: null,
message: null
};
conn.onopen = function (e) {
conn.send(JSON.stringify(client));
};
for (var i=0; i < str_array.length; i++) {
client.message = 'notifications';
client.token = '';
client.type = 'chat';
client.recipient_id = str_array[i].send(str_array.toString());
conn.send(JSON.stringify(client));
}
}
});