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