此处javascript中的代码在模式B中显示QR,其中在datatable href链接中显示模式:
$(function QR() {
$.ajax({
url: "servgenqr",
dataType: "json",
method: "GET",
success: function(response) {
$('.QRTable').dataTable({
data: response,
retrieve: true,
paging: true,
searching: true,
destroy: false,
language: {
searchPlaceholder: "Search records"
},
columns: [{
'data': 'amount'
},
{
'data': 'date'
},
{
"data": "codeQR",
"render": function(data, type, row, meta) {
if (type === 'display') {
var showqrcode = new QRCode(document.getElementById("qcodeQR"), {
width: 200,
height: 200
});
$("#qrlink").click(function() {
showqrcode.makeCode(data);
});
column = '<a id="qrlink" href="#showQR" class="fa fa-qrcode" data-toggle="modal" data-target="#showQR" style="font-size: 1.6em;"></a>';
}
return column;
}
}
]
});
$(".dataTables_filter input").addClass("form-control");
$(".dataTables_length select").addClass("form-control");
},
error: function(jqXHR, textStatus, errorThrown) {}
});
//setTimeout(startRefresh,1000);
});
此处的代码javascript显示模式A,其中从按钮显示模式:
var qrcode = new QRCode(document.getElementById("qrcode"), {
width: 200,
height: 200
});
function makeCode() {
qrcode.makeCode(makeQR());
}
$("#submit").click(
function() {
var amount = $("#amountField").val();
var qrcode = makeQR();
if (amount == '' || amount == null || amount == 0) {
$('#amountField').focus();
$('.error-message').show();
} else {
$('.error-message').hide();
$.ajax({
type: "POST",
data: {
Email: amount,
Pass: qrcode
},
url: "Transaction",
success: function(resp) {
makeCode();
$('#newQR').modal('show');
$("#success-alert").show();
setTimeout(function() {
$("#success-alert").slideUp(500);
}, 2000);
},
error: function(resp) {
makeCode();
$('#newQR').modal('show');
$("#success-alert").show();
$("#failed-alert").show();
setTimeout(function() {
$("#failed-alert").slideUp(500);
}, 2000);
}
});
}
});
如何删除双画布,或解决此问题的线索,谢谢。