Answer the question
In order to leave comments, you need to log in
How to make an ajax request in javascript?
Tell me, I'm writing a javascript script, I want to take a screenshot on the canvas (this will be a set of images that are formed when passing the questionnaire) and share it on a social network.
Total found this library
https://html2canvas.hertzen.com/
Further on js
window.onload = function() {
document.getElementById("qq").onclick = function() {
html2canvas(field).then(function(canvas) {
var my_screen = canvas.toDataURL('image/jpeg', 0.5)
console.log(my_screen)
document.getElementById("vk").addEventListener('click', function(){
window.open('https://vkontakte.ru/share.php?url='+my_screen+',sharer,status=0,toolbar=0,width=650,height=500')
})
});
};
}
window.open('https://vkontakte.ru/share.php?url='+my_screen+',sharer,status=0,toolbar=0,width=650,height=500')
<?php
$name = time().".jpg";
$check_save = @file_put_contents($name, base64_decode($_POST["data"]));
?>
Answer the question
In order to leave comments, you need to log in
To what extent the correct decision was formed in the head,Pretty standard solution.
and how to send an ajax request exactly on vanilla js?XMLHttpRequest or fetch, in fact, there is no difference, the only thing to take into account is that the data through the fetch will by default go to php://input , and not to $_POST, or you need to form a request with formData as the sent data structure.
Is it possible to solve the problem without a backend?No. It is not clear where this conclusion comes from ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question