if ('undefined' != typeof(StringBuffer)) {
StringBuffer = {};
}


StringBuffer = function(str) {
this._aString = [];
if ('undefined' != typeof(str)) {
  this.append(str);
}
};


StringBuffer.prototype.append = function(str) {
    this._aString.push(str);
    return this;
};


StringBuffer.prototype.toString = function() {
    return this._aString.join('');
};


StringBuffer.prototype.setLength = function(nLen) {
    if('undefined' == typeof(nLen) || 0 >= nLen) {
     this._aString.length = 0;
    } else {
     this._aString.length = nLen;
    }
};



'개발 > JQUERY' 카테고리의 다른 글

jquery 한글 영어 숫자 체크  (0) 2017.03.17
jquery datatable 컬럼 동적생성  (0) 2017.03.17
jquery datatable 테이블  (0) 2017.03.16
제이쿼리(Jquery) 파라메터 가져오기  (0) 2017.03.15
Jquery 한글 영어 체크하기  (0) 2017.03.13

var row = res.body.message.split("\n"); 
var wordArr = new Array(); 

for(var r=0; r<row.length-1; r++) { 
    var col = row[r].split("\t"); 
    var word = new Array(); 
    for(var c=0; c<col.length; c++) { 
        word.push(col[c]); 
    
    wordArr.push(word); 

$('#higFreqTable').DataTable({ 
    data: wordArr, 
    destroy: true 
}); 
$("#higFreqTable_filter").css("margin-right","70px");

컬럼이 고정일때 쓰는 방식
여기에 넘어오는 데이터는 
컬럼1 컬럼2 컬럼3 컬럼4 컬럼5
컬럼1 컬럼2 컬럼3 컬럼4 컬럼5
컬럼1 컬럼2 컬럼3 컬럼4 컬럼5

이런식으로 tab과 \n으로 구분됩니다.



'개발 > JQUERY' 카테고리의 다른 글

jquery 한글 영어 숫자 체크  (0) 2017.03.17
jquery datatable 컬럼 동적생성  (0) 2017.03.17
제이쿼리 stringbuffer  (0) 2017.03.17
제이쿼리(Jquery) 파라메터 가져오기  (0) 2017.03.15
Jquery 한글 영어 체크하기  (0) 2017.03.13

우선 json을 만드는 방법입니다.

{"mainList":[{"name":"john1","userId":"john11"},{"name":"john2","userId":"john22"}]}

예)

var totData = new Object();

var data = new Object();

var dataList = new Array();

data["name"] = "john1";

data["userId"] = "john11";

dataList.push(data);

var data = new Object();

data["name"] = "john2";

data["userId"] = "john22";

dataList.push(data);

totData["mainList"] = dataList;

console.log(totData);


이런식으로 만들어서

ajax 호출로 던짐 꼭 json 형식이 아니여도 form serialize 방식으로 던져도 되구요

$.ajax({

contentType:'application/json',

dataType : 'json',

data : JSON.stringify(totData),

url : 'test.json', 

type : 'POST',

success:function(data){

}

});


constroll 단에서  받기


@RequestMapping(value = "/test.json", method=RequestMethod.POST)

@ResponseBody

public Result test(Result result, @RequestBody testVO param) throws Exception {

for(testVO str : param.getMainList()) {

System.out.println("name-------------->"+str.getName()); 

System.out.println("userId-------------->"+str.getUserId()); 

}

}


VO 단


public class testVO {

private String name;

private String userId;


private List<testVO> mainList;


public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getUserId() {

return userId;

}

public void setUserId(String userId) {

this.userId = userId;

}

public List<testVO> getMainList() {

return mainList;

}

public void setMainList(List<Wms151002VO> mainList) {

this.mainList = mainList;

}

}


혹시 dhtmlx 를 쓰시는 분은(제가 지금 dhtmlx플젝이라...)

var mainDataList = new Array();

var totData = new Object();

mainGrid.forEachRow(function(id){

var data = new Object();

mainGrid.forEachCell(id, function(cellObj,ind){

var columnName = mainGrid.getColumnId(ind);

var columnValue = mainGrid.cells(id,ind).getValue();

 

data[columnName] = columnValue;

});

mainDataList.push(data);

});

totData["mainList"] = mainDataList;

console.log(JSON.stringify(totData)); 


요런 식으로??ㅎㅎㅎㅎㅎㅎ

+ Recent posts