ByteScout Cloud API Server - Barcode Generator API - JavaScript - Generate Barcode - Async API - ByteScout

ByteScout Cloud API Server – Barcode Generator API – JavaScript – Generate Barcode – Async API

  • Home
  • /
  • Articles
  • /
  • ByteScout Cloud API Server – Barcode Generator API – JavaScript – Generate Barcode – Async API

How to generate barcode async API for barcode generator API in JavaScript and ByteScout Cloud API Server

Learn to write code generate barcode async API for barcode generator API in JavaScript: Simple How To Tutorial

Check these thousands of pre-made source code samples for simple implementation in your own programming projects. Barcode generator API in JavaScript can be applied with ByteScout Cloud API Server. ByteScout Cloud API Server is the ready to use Web API Server that can be deployed in less than 30 minutes into your own in-house server or into private cloud server. Can store data on in-house local server based storage or in Amazon AWS S3 bucket. Processing data solely on the server using buil-in ByteScout powered engine, no cloud services are used to process your data!.

The SDK samples displayed below below explain how to quickly make your application do barcode generator API in JavaScript with the help of ByteScout Cloud API Server. This JavaScript sample code can be used by copying and pasting into your project. Once done,just compile your project and click Run. Further improvement of the code will make it more robust.

Free! Free! Free! ByteScout free trial version is available for FREE download from our website. Programming tutorials along with source code samples are assembled.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

generate_barcode.js
      
// Please NOTE: In this sample we're assuming Cloud Api Server is hosted at "https://localhost". // If it's not then please replace this with with your hosting url. function generateBarcode() { // Hide result blocks document.getElementById("errorBlock").style.display = "none"; document.getElementById("resultBlock").style.display = "none"; // Get barcode type var barcodeType = document.getElementById("barcodeType").value; // Get barcode value var inputValue = document.getElementById("inputValue").value.trim(); if (inputValue == null || inputValue == "") { alert("Barcode Value should not be empty."); return false; } //show loader showLoader(true); // Prepare URL var url = "https://localhost/barcode/generate?name=barcode.png"; url += "&type=" + barcodeType; // Set barcode type (symbology) url += "&value=" + inputValue; // Set barcode value url += "&async=True"; // Set async api // Prepare request var httpRequest = new XMLHttpRequest(); httpRequest.open("GET", url, true); // Asynchronous response handler httpRequest.onreadystatechange = function () { if (httpRequest.readyState == 4) { // If OK if (httpRequest.status == 200) { var result = JSON.parse(httpRequest.responseText); checkIfJobIsCompleted(result.jobId, result.url); } // Else display error else { document.getElementById("errorBlock").style.display = "block"; // show hidden errorBlock document.getElementById("error").innerHTML = "Request failed. Please check you use the correct API key."; // Hide loader showLoader(false); } } } // Send request httpRequest.send(); return true; } function checkIfJobIsCompleted(jobId, resultFileUrl) { var url = 'https://localhost/job/check?jobid=' + jobId; // Prepare request var httpRequest = new XMLHttpRequest(); httpRequest.open("GET", url, true); // Asynchronous response handler httpRequest.onreadystatechange = function () { if (httpRequest.readyState == 4) { // If OK if (httpRequest.status == 200) { var jobResult = JSON.parse(httpRequest.responseText); if (jobResult.status == "working") { // Check again after 3 seconds setTimeout(function(){ checkIfJobIsCompleted(jobId, resultFileUrl); }, 3000); } else if (jobResult.status == "working") { document.getElementById("resultBlock").style.display = "block"; // show hidden resultBlock document.getElementById("image").setAttribute("src", resultFileUrl); // Set image link to display // Hide loader showLoader(false); } } // Else display error else { document.getElementById("errorBlock").style.display = "block"; // show hidden errorBlock document.getElementById("error").innerHTML = "Request failed. Please check you use the correct API key."; // Hide loader showLoader(false); } } } // Send request httpRequest.send(); } function showLoader(isDisplay) { var loader = document.getElementById("loader"); if (isDisplay) { loader.style.display = ""; } else { loader.style.display = "none"; } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Cloud API Server Home Page

Explore ByteScout Cloud API Server Documentation

Explore Samples

Sign Up for ByteScout Cloud API Server Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Cloud API Server Home Page

Explore ByteScout Cloud API Server Documentation

Explore Samples

Sign Up for ByteScout Cloud API Server Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next