내 작업은 handsontable에서 json 파일로 데이터를 저장하는 것입니다."Object가 getData 속성 또는 메서드를 지원하지 않습니다. "오류,"제출 "버튼을 클릭하십시오. 다음 코드를 살펴보고 알려주세요, 내가 잘못 갔다. 미리 감사드립니다. Handsontable의 getData()는 "Object가 속성 또는 메서드 'getData'를 지원하지 않습니다. 오류
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1./jquery.min.js" type="text/javascript"></script>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.3.js'></script>
<script src="http:\\localhost\NetOptUI2\bin\jquery-handsontable-master\dist_wc\x-handsontable\jquery.handsontable.full.js"></script>
<link rel="stylesheet" media="screen" href="http:\\localhost\NetOptUI2\bin\jquery-handsontable-master\dist_wc\x-handsontable\jquery.handsontable.full.css">
</head>
<body>
<h3 class="title">MHEX Time Sample</h3>
<div id="handsontable">
<div id="divButtons">
<input type="Button" name="submit" value="submit" class="btnSubmit"/>
</br>
</br>
Console: </br>
<span id="exampleconsole"></span>
</div>
</div>
<script>
var $container = $("#handsontable");
var handsontable = $container.data('handsontable');
var data = [
var data = [
["", "Maserati", "Mazda", "Mercedes", "Mini", "Mitsubishi"],
["2009", 0, 2941, 4303, 354, 5814],
["2010", 5, 2905, 2867, 412, 5284],
["2011", 4, 2517, 4822, 552, 6127],
["2012", 2, 2422, 5399, 776, 4151]
var config = {
data: data,
minRows: 15,
minCols: 6,
minSpareRows: 1,
autoWrapRow: true,
colHeaders: true,
currentRowClassName: 'currentRow',
currentColClassName: 'currentCol',
contextMenu: { items: {
"row_above": {},
"row_below": {},
"hsep1": "---------",
"col_left": {},
"col_right": {},
"hsep2": "---------",
"remove_row": {},
"remove_col": {}
}
}
};
$("#divButtons").find(".btnSubmit").click(function() {
$.ajax({
url: "json/save.json",
data: {"data": handsontable.getData()}, //returns all cells' data
dataType: 'json',
type: 'POST',
success: function (res) {
if (res.result === 'ok') {
console.text('Data saved');
}
else {
console.text('Save error');
}
},
error: function() {
console.text('Save error. POST method is not allowed on GitHub Pages. Run this example on your own server to see the success message.');
}
});
});
$("#handsontable").handsontable(config);
var console = $("#divButtons").find("#exampleconsole");
console.text("Initialized....");
</script>
</body>
</html>
'HTTP : \\ localhost를 \'? 콘솔 오류를 확인하십시오 – karthikr
위의 html을 IE, Chrome 등에서 열면 위의 오류가 브라우저의 콘솔에 나타납니다. wampserver.Thats 왜 http : // localhost /를 사용하고 있습니다. – user2791530