Last active
May 27, 2024 12:00
-
-
Save nifrasismail/574554b3dcabcf6fb13edf6a541b1501 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var reponseArray = []; | |
// Printing Job | |
async function printer(barcode,productLine,numberOfCopies,rcvdDate) { | |
var xmlHttp = new XMLHttpRequest(); | |
xmlHttp.open("GET", '/barcode/get-script-url?barcode='+barcode+'&productLine='+productLine+'&numberOfCopies='+numberOfCopies+'&rcvdDate='+rcvdDate+'', false); // false for synchronous request | |
xmlHttp.send(null); | |
var response = await xmlHttp.responseText; | |
var responseObj = JSON.parse(response); | |
loadScript(responseObj.scripturl, function () { | |
window.jsWebClientPrint.print('useDefaultPrinter=true' + '&printerName=' + $('#installedPrinterName').val()); | |
}); | |
} | |
// Loading the printing script | |
async function loadScript(url, callback) { | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
if (script.readyState) { | |
script.onreadystatechange = function () { | |
if (script.readyState == "loaded" || | |
script.readyState == "complete") { | |
script.onreadystatechange = null; | |
callback(); | |
} | |
}; | |
} else { | |
script.onload = function () { | |
callback(); | |
}; | |
} | |
script.src = url; | |
await document.getElementsByTagName("head")[0].appendChild(script); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment