Ad Unit (Iklan) BIG

short url generate api in jquery ajax call


<!DOCTYPE html>
<html>
<head>
    <style>
        a{
            color: goldenrod;
        }
    </style>
    <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
</head>
<body>
    <input type="text" id="url_txt"><br><br>
    <span id="resurl"></span>
    <script>
        var user_url = "https://ajayvishu.blogspot.com";
        $("#url_txt").on("change", function () {
            var user_url = $(this).val();
            var url = "https://api.shrtco.de/v2/shorten?url=" + user_url;
            $.getJSON({
                url: url,
                success: function (data) {
                    var short_link = data.result.full_short_link;
                    console.log(short_link.substr(8));
                    $("#resurl").html(short_link.link(short_link.substr(8)));
                }
            });
        });
        $("#resurl").on("mouseenter",function () {
            window.open($(this).text());
        });
    </script>
</body>
</html>

Post a Comment

0 Comments