Hi YulIhnio,
After getting value in textbox call ajax method to insert data.
Check below code.
<script type="text/javascript">
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
scanner.addListener('scan', function (contenido) {
var test = contenido.toString();
document.getElementById('<%= HiddenField1.ClientID %>').value = test;
$("#<%= txt_Person_Nm.ClientID %>").val($('#<%= HiddenField1.ClientID %>').val());
var obj = {};
obj.code = $("#<%= txt_Person_Nm.ClientID %>").val();
$.ajax({
type: "POST",
url: "Default.aspx/SaveCode",
data: JSON.stringify(obj),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
alert(r.d);
}
});
});
Instascan.Camera.getCameras().then(function (cameras) {
if (cameras.length > 0) {
scanner.start(cameras[0]);
} else {
console.error('There is no camara');
}
}).catch(function (e) {
console.error(e);
});
</script>
for inserting data into database using ajax refer below article.