Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught (in promise) Provided element is not within a Document

I am trying to screenshot and download it to server, but still getting error. It´s a Wordpress BTW.

Uncaught (in promise) Provided element is not within a Document

jQuery

<script>
function takeScreenshot(){
var element = jQuery("#vpc-preview");
html2canvas(element,{
background:'#FFFFFF',
onrendered:function(canvas){
var imgData = canvas.toDataURL('image/jpeg');
$.ajax({
url:'/wp-content/plugins/html2canvas/save.php',
type:'post',
dataType:'text',
data:{base64data:imgData}
});
}
});
}
</script>

Any help?

like image 869
Userman Avatar asked Jan 16 '18 22:01

Userman


Video Answer


1 Answers

element in your code is a jQuery object, not an element

Try

var element = jQuery("#vpc-preview")[0];
like image 62
charlietfl Avatar answered Oct 19 '22 14:10

charlietfl