如何在旧CI中使用javascript成功函数传递值

i'm working with an old codeigniter. i'm calling a onchange function. i want to get data from controller and show it to a input filed which is an array.

view page code:

    <select name='feed_id[]' style='width:95px;'onchange="getfeedstock(0,this.value)"><?=$this->mod_feed->get_feeds()?></select>

<span><input type='text' name='stock[]' readonly value='' class='num_txt stock<?=$inc?>' /></span>

javascript:

<script >

    function getfeedstock(i,obj){
        //alert(obj);
        $.ajax({
            url:base_url+'feed_sale/get_feed_stock',
            type:'post',
            data:{
                feed_id:feed_id

            },
            success:function(data){
                //alert(data);
                //var stock=5;
                 //$('.stock').val(stock);
            },
            error:function(error,msg){
                alert(error+msg);
            }
        });
    }
</script>

Use Output class of Codeigniter https://www.codeigniter.com/userguide2/libraries/output.html

it will set page header to JSON type. And pass array using json_encode();

all array of PHP will get in JSON object format in success callback of Ajax

success: function(data) {
    alert(data.msg); // showing [Object][object] 
    //all array visible in console log Ctrl+Shift+I (in chrome)
    console.log(data);
}