Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
For loop is not working properly in javascript with PHP

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));  
        }
    }
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!