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

147
Views
How to integrate Php array to Javascript Using Ajax

I am working on ajax and php,I want to use Php array in javascript,But right not unable to integrate Php array to javascript, Here is my Controller code where i am getting Php array as json(Using Json encode)

function GetFollowingCoinUsers()
        {
            $CoinId=$_POST['coin_id'];
            $result = $this->M_main->GetAllCoinFollower($CoinId);
            $UserId=array();
            foreach($result as $res)
            {
                $UserId[]=$res['UserId'];
            }
            echo json_encode($UserId);
        }

Above code give me result in following way

["463","500","505"]

And i am trying to use this array in Javascript/Ajax Response

$.ajax({
            type: "post",
            url:'<?php echo base_url();?>Main/GetFollowingCoinUsers',
            data: {coin_id:coin_id},
            success: function (datan) {
                    var cars = datan;
                    let text = "";
                    for (let i = 0; i < cars.length; i++) {
                      text += cars[i] + "<br>";
                    }
                    alert(text);
                    
            }
        });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can try this:

yourArray = [];

JSON.parse(yourArray.replace(/&quot;/g,'"'));
about 4 years ago · Juan Pablo Isaza Report
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!