• jquery 将2维数据逐条写入表格


    1.
    [esb@esbapp5 sbin]$ cat a1.sh
    echo 'aaaaaaaaaaaaa'
    ppplll
    echo 'bbbbbbbbbbbbbb'
    echo 'cccccccccccccc'
    echo 'dddddddddddddd'
    echo 'eeeeeeeeeeeeee'
    echo 'ffffffffffffff'
    echo 'gggggggggggggg'
    
    发布信息
    /app/esb/sbin/a1.sh: line 2: ppplll: command not found
    aaaaaaaaaaaaa
    bbbbbbbbbbbbbb
    cccccccccccccc
    dddddddddddddd
    eeeeeeeeeeeeee
    ffffffffffffff
    gggggggggggggg 
    
    
    [[u'/app/esb/sbin/a1.sh: line 2: ppplll: command not found
    '], [u'aaaaaaaaaaaaa
    ', u'bbbbbbbbbbbbbb
    ', u'cccccccccccccc
    ', u'dddddddddddddd
    ', u'eeeeeeeeeeeeee
    ', u'ffffffffffffff
    ', u'gggggggggggggg
    ']]
    <type 'list'>
    
    返回的是一个2位数组:
    
    
    $(function(){
          	var _env_select = $("select[name='application']");
    	var _ip_select = $("select[name='deployip']");
            var _machine_select = $("select[name='deploymachine']");
            var _deploypkg_select = $("select[name='deploypkg']");
    	var _sub_btn = $(".publish");
            var _qmgr_btn = $(".check");
            var _table = $("table.gridtable");
            getTemp("pro");
    	getdeploypkg("xx");
           	function getTemp(env){
    		var data = {};
    		var successfn = function(jdata){
    			var _HTML = "";
    			_env_select.html("");
    			$.each(jdata,function(i,val){
    				_HTML = _HTML + "<option value="+jdata[i][0]+">"+jdata[i][0]+"</option>";
    			});
    			_env_select.html(_HTML);
    		};
    		var errorfn = function(jdata){
    			alert("数据返回出错");
    		};
    		
    		$.ajax({
                type: "get",
                data: data,
                url: "/api/getdeployapp",
    			dataType: "json",
                success: function(d){
                    successfn(d);
                },
                error: function(e){
                    errorfn(e);
                }
            });
    	};
    	
    	
    	 	function getdeploypkg(env){
    		var data = {};
    		var successfn = function(jdata){
    			var _HTML = "";
    			_deploypkg_select.html("");
    			$.each(jdata,function(i,val){
    				_HTML = _HTML + "<option value="+jdata[i]+">"+jdata[i]+"</option>";
    			});
    			_deploypkg_select.html(_HTML);
    		};
    		var errorfn = function(jdata){
    			alert("数据返回出错");
    		};
    		
    		$.ajax({
                type: "get",
                data: data,
                url: "/api/listdeployfile",
    			dataType: "json",
                success: function(d){
                    successfn(d);
                },
                error: function(e){
                    errorfn(e);
                }
            });
    	};
    
    	Transaction = function(){
    		this.selectedIp = function(){
    			var data = {};
    			data.env = _env_select.val();
    			var successfn = function(jdata){
    				var _HTML = "";
    				_ip_select.html("");
    				$.each(jdata,function(i,val){
    					_HTML = _HTML + "<option value="+jdata[i][0]+">"+jdata[i][0]+"</option>";
    				});
    				_ip_select.html(_HTML);
    			};
    			var errorfn = function(jdata){
    				alert("数据返回出错");
    			};
    			
    			$.ajax({
    				type: "get",
    				data: data,
    				url: "/api/deployip",
    				dataType: "json",
    				success: function(d){
    					successfn(d);
    				},
    				error: function(e){
    					errorfn(e);
    				}
    			});
    		};
    		
    		this.selectMahine = function(){
    			var data = {};
    			data.env= _env_select.val();
    			data.ip = _ip_select.val();
    			var successfn = function(jdata){
    				var _HTML = "";
    				_machine_select.html("");
    				$.each(jdata,function(i,val){
    					_HTML = _HTML + "<option value="+jdata[i][0]+">"+jdata[i][0]+"</option>";
    				});
    				_machine_select.html(_HTML);
    			};
    			var errorfn = function(jdata){
    				alert("数据返回出错");
    			};
    			
    			$.ajax({
    				type: "get",
    				data: data,
    				url: "/api/deploymachine",
    				dataType: "json",
    				success: function(d){
    					successfn(d);
    				},
    				error: function(e){
    					errorfn(e);
    				}
    			});
    		};
    		
    	
    			
    	  };
    	var transactionGet1 = new Transaction();
    	transactionGet1.selectedIp();
    	_env_select.on('change',function(){
    		transactionGet1.selectedIp();
    	})
    	
    	
    	
    	var transactionGet2 = new Transaction();
    	transactionGet2.selectMahine();
    	_ip_select.on('change',function(){
    		transactionGet2.selectMahine();
    	})
    	
    	_sub_btn.on("click",function(){
    		var data = {};
    		data.name = _env_select.val();
    		/*data.desc = _select_ip.find("option:selected").text();*/
    		data.ipaddr = _ip_select.val()
                    data.deploypkg=_deploypkg_select.val()
                    data.deploymachine=_machine_select.val()
                    var successfn = function(jdata){
                   /*var jdata = eval(jdata);*/
                   $(".gridtable").empty();
                   var _HTML="<tr><td>发布信息</td></tr>";
                   for(var L1=0;L1<jdata.length;L1++){
                         var newArr = jdata[L1];
                         console.log(newArr);
                         for (var L2=0;L2<newArr.length;L2++){
    			  _HTML =_HTML +'<tr><td>'+ newArr[L2]+'</td></tr>'
                        };
    	          };
                    console.log(_HTML);
                    $(".gridtable").html(_HTML);
                    };
    		var errorfn = function(jdata){
    			alert("数据返回出错");
    		};
            $.ajax({
                type: "get",
                data: data,
                url: "/api/deploypublish",
                dataType: "json",
                success: function(d){
                      successfn(d);
                },
                error: function(e){
                    errorfn(e);
                }
            });
    	});
    	
    })

  • 相关阅读:
    day08作业
    day07作业
    day06作业
    day05作业
    OOAD与UML
    大数据(3):基于sogou.500w.utf8数据Hbase和Spark实践
    大数据(2):基于sogou.500w.utf8数据hive的实践
    大数据(1):基于sogou.500w.utf8数据的MapReduce程序设计
    九大排序算法的Java实现
    数字在排序数组中出现的次数
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349245.html
Copyright © 2020-2023  润新知