weixin_33717298 2014-12-17 10:22 采纳率: 0%
浏览 18

Ajax响应数组

I want to insert ajax response array into form select input. for the purpose i want to look into array. here is my function;

function _get_student_failed_classes()
{
$failed_classes=$this->db->select('class_student.class_id,course.course_code,course.course_name,course.course_credit')
        ->join('class','class.class_id=class_student.class_id','LEFT')
        ->join('course','course.course_id=class.class_course','LEFT')
        ->where('class.class_status',$active)
        ->where('class_student.class_marks <=',50)
        ->where('class_student.student_id',$std_code)
        ->order_by('class.class_id')
        ->get('class_student')->result();
echo $failed_classes;
}

and here is my ajax call in form

$.ajax({
        url: '<?php echo base_url()."index.php/student/get_student_failed_classes/s-14-1"; ?>',
        type: 'POST',   data: std_code,
        success: function(response)
        {

          alert(response);

        },
        error: function()
        {
          alert(error);
        }

I get the response is []

the actual array looks like this

Array
(
[0] => stdClass Object
    (
        [class_id] => 3
        [course_code] => cs3
        [course_name] => cs3
        [course_credit] => 3
    )

[1] => stdClass Object
    (
        [class_id] => 4
        [course_code] => cs4
        [course_name] => cs4
        [course_credit] => 4
    )

[2] => stdClass Object
    (
        [class_id] => 5
        [course_code] => cs5
        [course_name] => cs5
        [course_credit] => 3
    )

)

can some one help me out on this

  • 写回答

2条回答 默认 最新

  • weixin_33695082 2014-12-17 10:26
    关注
    var objectRet= jQuery.parseJSON(response);
    for(var i=0;i<objectRet.length;++i) {
       alert(objectRet[i].class_id)
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效