楚江临 2021-10-15 16:30 采纳率: 33.3%
浏览 55

我想通过草料二维码的api,将我生成的二维码进行美化, api的文档是 https://cli.im/api 。我上面写的function testNetRequest()好像不行

img


<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
    <head>
        <title>Cross-Browser QRCode generator for Javascript</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
        <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
        <script type="text/javascript" src="qrcode.min.js"></script>
    </head>
    <body>
        <input id="text" type="text" value="http://jindo.dev.naver.com/collie"
            style="width:80%; text-align: center;" /><br />
        <p style="display: inline-block;">宽度</p>
        <input id="code_width" type="number" value="200"
            style="width:9.375rem; text-align: center; display: inline-block;" />
        <br />
        <p style="display: inline-block;">高度</p>
        <input id="code_height" type="number" value="200"
            style="width:9.375rem; text-align: center; display: inline-block;" /><br />
        <div>
            <button id="make_code" onclick="makeCode()">生成二维码</button>
            <button id="make_code" onclick="testNetRequest()">美化二维码</button>
        </div>
        <div id="qrcode" style="min-width:100px; min-height:100px; margin-top:15px; "></div>

        <script type="text/javascript">
            function makeCode() {
                var elText = document.getElementById("text");
                if (!elText.value) {
                    alert("Input a text");
                    elText.focus();
                    return;
                }
                //清空之前生成的
                $('#qrcode').html("");
                //重新生成
                var qrcode = new QRCode(document.getElementById("qrcode"), {
                    width: $("#code_width").val(),
                    height: $("#code_height").val(),
                    colorDark: "#000000",
                    colorLight: "#ffffff",
                    correctLevel: QRCode.CorrectLevel.H
                });
                qrcode.makeCode(elText.value);
            }

            makeCode();
            $("#text").
            on("blur", function() {
                makeCode();
            }).
            on("keydown", function(e) {
                if (e.keyCode == 13) {
                    makeCode();
                }
            });
        </script>
        <script src="netrequest/jquery-3.3.1.js"></script>
        <script>
            function testNetRequest() {}
        </script>
        <script>
            function testNetRequest() {
                // var a = document.getElementById("text").value
                // alert(a)
                $.ajax({
                    type: "get",
                    url: "https://cli.im/api/qrcode/code?text=asdasdasda&mhid=sELPDFnok80gPHovKdI",
                    async: true,
                    success: function(data) {
                        alert(data)
                    },
                    error: function(data) {
                        alert(data)
                    }
                });
            }
        </script>
        <script>
        </script>
    </body>
</html>
  • 写回答

1条回答 默认 最新

报告相同问题?

问题事件

  • 创建了问题 10月15日

悬赏问题

  • ¥20 python忆阻器数字识别
  • ¥15 无法输出helloworld
  • ¥15 高通uboot 打印ubi init err 22
  • ¥20 PDF元数据中的XMP媒体管理属性
  • ¥15 R语言中lasso回归报错
  • ¥15 网站突然不能访问了,上午还好好的
  • ¥15 有没有dl可以帮弄”我去图书馆”秒选道具和积分
  • ¥15 semrush,SEO,内嵌网站,api
  • ¥15 Stata:为什么reghdfe后的因变量没有被发现识别啊
  • ¥15 振荡电路,ADS仿真