How to set the value of text dynamically in jQuery.qrcode

441 views Asked by At

I tried to populate the qrcode using the latest DateTime using the code below but nothing happens. But If I tried to manually set a value on the text the qrcode displays.

I'm using this plugin

var options = "";
    var url_date = "@Url.Action("GetDate", "Test")"
    $.get(url_date, function (e) {

        $("span[class='DatePrinted']").html(e);
        console.log("DatePrinted: " + e);

        options = {
            render: 'div',
            minVersion: 1,
            maxVersion: 1,
            ecLevel: 'L',
            left: 0,
            top: 0,
            size: 75,
            text: e.toString(),
            radius: 0,
            quiet: 0,
            mode: 0
        }
    }).done(function () {
        $("div[class='qr_code']").qrcode(options);
    });
1

There are 1 answers

0
Rajon Kobir On
        // clearing the inner html first
        $("#qr_code").html("");
        $('#qr_code').qrcode({
          render: 'canvas', 
          width: 140, 
          height: 140, 
          text: data,  // data is a variable
          // mode: 3,
          // image:"./URLSHRT/Pagelogo.png",
          // mode: 1, 
          // label:'www.urlshrt.co',
          // fontname:'sans',
          // fontcolor:'#000',
          // background:'#000', 
          // foreground:'#FD5353', 
          // padding : 50
        });