rails Ajax--利用Jquery

时间:2014-06-11 08:03:40   收藏:0   阅读:245

view

function init_tree(product_name) {
  var htmlobj=$.ajax({url: "get_all_file?param=" + param_value,  async: false});
  var jsonNodes = htmlobj.responseText;
  var newNodes = $.parseJSON(jsonNodes);
  //使用newNodes更新页面
}

 

controller

bubuko.com,布布扣
def get_all_file
    # 为@file_tree赋值
    @file_tree=[{:id => code, :pId => p_code, :name => file}, {:id => code1, :pId => p_code1, :name => file1}]
    respond_to do |format|
      format.json { render :json=> @file_tree }
    end
  end
bubuko.com,布布扣

 

rails Ajax--利用Jquery,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!