在邮政请求中发送一个** Promise ** JavaScript中的值
我在html
中有一个简单的表单,看起来像这样:
<form method="post" id="postImageForm" action="storeImage.php">
<input type="hidden" name="image" id="image-tag">
<button class="capture-button" type="submit" value="submit"></button>
</form>
javaScript EventListner
:
PostForm.addEventListener('submit', function(e){
e.preventDefault();
let imageTag = document.getElementById('image-tag');
html2canvas(displayScreen).then(canvas=>{
imageTag.value = canvas.toDataURL();
appendThumbnail(canvas.toDataURL());
console.log("inside the promise: "+imageTag.value) //valid results.
});
console.log("outside the promise: "+imageTag.value); //empty results.
})
我的 php 文件接收空值,我的console.log()
Promise 范围之外。
如何修复将值发送到post
中?
I have a simple form in html
that looks like this:
<form method="post" id="postImageForm" action="storeImage.php">
<input type="hidden" name="image" id="image-tag">
<button class="capture-button" type="submit" value="submit"></button>
</form>
and a Javascript eventListner
:
PostForm.addEventListener('submit', function(e){
e.preventDefault();
let imageTag = document.getElementById('image-tag');
html2canvas(displayScreen).then(canvas=>{
imageTag.value = canvas.toDataURL();
appendThumbnail(canvas.toDataURL());
console.log("inside the promise: "+imageTag.value) //valid results.
});
console.log("outside the promise: "+imageTag.value); //empty results.
})
my php file receives empty value and so is my console.log()
outside the promise scope.
How can it be fixed to send the value into POST
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论