<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>DMTServerWeb :: Endpoint Test</title>
<script src="js/jquery-1.12.4.min.js"></script>
<script src="js/json-view/jquery.json-view.min.js" type="text/javascript"></script>
<link href="js/json-view/jquery.json-view.min.css" rel="stylesheet"/>
</head>
<body>
<h1>DMTServerWeb :: Endpoint Test</h1>
<h2>/upload/zip endpoint</h2>
<form id="form">
<table>
<tr style="vertical-align:top;"><th>method</th><th>path</th><th>ZIP File</th></tr>
<tr style="vertical-align:top;"><td>POST</td><td>/survey/upload</td>
<td>
<input type="file" name="zipFile" size="45" accept=".zip" /><br/>
</td>
</tr>
</table>
</form>
<button type="button" id="testit_button" onclick="javascript:testit();">Test it!</button>
<div id="resultDiv" style="border: 1px solid #AAA; background-color: #F5F5F5; padding: 20px; margin-top: 20px;"></div>
<script type="text/javascript">
function testit ()
{
$('#resultDiv').html('Waiting response...');
$('#test_it').prop( "disabled", true );
var fd = new FormData(document.getElementById("form"));
$.ajax({
url: "rest/upload/zip"
, type: "POST"
, contentType: false
, processData: false
, data : fd
, headers: {"TOKEN": "xxxx"}
, cache: false
}).then(function(data, status, jqxhr) {
$('#resultDiv').html("");
$('#resultDiv').jsonView(JSON.stringify(data, undefined, 4));
//console.log(jqxhr);
$('#test_it').prop( "disabled", false );
});
}
</script>
</body>
</html>