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

如何在旧CI中使用javascript成功函数传递值,javascript,php,codeigniter,Javascript,Php,Codeigniter,我在和一个旧的代码点火器一起工作。我正在调用onchange函数。我想从控制器中获取数据,并将其显示到一个作为数组的输入字段中 查看页面代码: <select name='feed_id[]' style='width:95px;'onchange="getfeedstock(0,this.value)"><?=$this->mod_feed->get_feeds()?></select> <span><input ty

我在和一个旧的代码点火器一起工作。我正在调用onchange函数。我想从控制器中获取数据,并将其显示到一个作为数组的输入字段中

查看页面代码:

    <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>


使用Codeigniter的输出类

它将页面标题设置为JSON类型。并使用json_encode()传递数组

在Ajax的成功回调中,所有PHP数组都将以JSON对象格式获得

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

使用Codeigniter的输出类

它将页面标题设置为JSON类型。并使用json_encode()传递数组

在Ajax的成功回调中,所有PHP数组都将以JSON对象格式获得

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