我希望每次单击按钮时都能将每个值记录为中央文件中的一行文本
逐行显示'var text ='
的值。
当我说中央文件时,我对任何建议,轻量级数据库或任何简单的解决方案持开放态度。这仅用于记录每次使用工具时的日志,并保留所选内容的日志。只需快速简单地审核我的工具即可。
HTML
<script src="jquery-git.js" type="text/javascript"></script>
<select name="option" id="option_id">
<option value="1">[No number listed]</option>
<option value="2">[Not answered]</option>
<option value="3">[Answered – not oncall – assisted with issue]</option>
<option value="4">[Answered – not oncall – unavailable]</option>
<option value="5">[Answered – oncall - unavailable]</option>
<option value="6">[Answered – oncall - available]</option>
</select>
<button name="Log" type="submit" id="Log-submit" data-submit="...Sending">Log</button>
JS
$(document).ready(function() {
$('#Log-submit').on('click', function(e) {
e.preventDefault();
var btn = $(e.target);
btn.attr("disabled", "disabled"); // disable button
var url = 'https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
var text = $("#option_id option:selected").text(); //Payload
console.log(text);
$.ajax({
data: 'payload=' + JSON.stringify({
"text": text
}),
dataType: 'json',
processData: false,
type: 'POST',
url: url
});
});
});
示例文件 - 记录10个值后
[Answered – not oncall – assisted with issue]
[Answered – not oncall – assisted with issue]
[Answered – not oncall – unavailable]
[Answered – oncall - available]
[Answered – oncall - available]
[Answered – not oncall – assisted with issue]
[Answered – not oncall – assisted with issue]
[Answered – not oncall – unavailable]
[Answered – not oncall – unavailable]
[Answered – not oncall – unavailable]