Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 76290

How to return value from an asynchronous javascript function in an iframe? [duplicate]

$
0
0

I have this java-script function with an asynchronous callback. I tried [looking for an answer here][1], but I do not enough javascript to replicate what people have answered. After several attempts and hours, I am still nowhere close.

I have a very simple function with no parameters, and no url. All the answers given have those components, which I am not able to figure out at all how to make the function return the string imageData.

Any help would be appreciated.

function getTable() {
    var canvas;
    var imageData;
    return html2canvas($("#example"), {
        // console.log("converting this into image");
        onrendered: function (canvas) {
            getCanvas = canvas;
            imageData = getCanvas.toDataURL("image/PNG");
            console.log(imageData);
            return imageData;
        }
    });


};

When I console log my imageData variable, I am getting exaclty what I want. How can I pass this exact variable so that when I run my function from other page I get that string of a base64 image??

Please let me know if you need any additional info about this.


Viewing all articles
Browse latest Browse all 76290

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>