Cloud API - Barcode Generator API - JavaScript - Generate Barcode (JQuery) - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

Cloud API – Barcode Generator API – JavaScript – Generate Barcode (JQuery)

  • Home
  • /
  • Articles
  • /
  • Cloud API – Barcode Generator API – JavaScript – Generate Barcode (JQuery)

Cloud API – Barcode Generator API – JavaScript – Generate Barcode (JQuery)

generate_barcode.js

$(document).ready(function () {
    $("#resultBlock").hide();
    $("#errorBlock").hide();
});

$(document).on("click", "#submit", function () {
    var apiKey = $("#apiKey").val().trim(); // Get your API key by registering at https://app.pdf.co/documentation/api

    var url = "https://api.pdf.co/v1/barcode/generate?name=barcode.png";
    url += "&type=" + $("#barcodeType").val(); // Set barcode type (symbology)
    url += "&value=" + $("#inputValue").val(); // Set barcode value

    $.ajax({
        url: url,
        type: "GET",
        headers: {
            "x-api-key": apiKey
        },
    })
    .done (function(data, textStatus, jqXHR) { 
        if (data.error == false) {
            $("#resultBlock").show();
            $("#image").attr("src", data.url);
        }
        else {
            $("#errorBlock").show();
            $("#error").html(data.message);
        }
    })
    .fail (function(jqXHR, textStatus, errorThrown) { 
        $("#errorBlock").show();
        $("#error").html("Request failed. Please check you use the correct API key.");
    });
});


  Click here to get your Free Trial version of the SDK

Tutorials:

prev
next