javascript - 使用 AJAX 发送更多数据
问题描述
我有一个小程序,可以将 div 转换为画布,然后像照片一样保存在服务器中。问题如下:我正在使用 ajax 发送图像的 php 数据,但我需要发送必要的 id,这是代码:
function(){
html2canvas(document.getElementById("contenedor-pizarra-postural")).then(function (canvas) {
//Here is the ID thats i need to send
let idConsulta = document.getElementById("idConsulta").value;
var ajax = new XMLHttpRequest();
ajax.open("POST", "php/cargarPlanillas.php", true);
ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//This is working only for the image data but i need to send the idConsulta variable :(
ajax.send("imagePostural=" + canvas.toDataURL("image/jpeg", 0.9))
})
ajax.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
console.log(this.responseText);
}
};
});
}
解决方案
推荐阅读
- regex - 用于验证特定正则表达式输入的正则表达式字符串
- node.js - 为我的移动应用程序选择最合适的平台来开发支持(数据访问服务层)
- c# - 如何更改richtextbox中选定文本的字体
- python - django 如何在查询集或序列化程序中自然地更改时间格式
- sql - Oracle 数据库 11gR2 快捷版
- spring-boot - 没有可用于服务的服务器:localhost
- c# - Assembly-CSharp.csproj 错误和 Intellisense 在 VSCode 中不起作用
- spring-boot - 使用 Spring Webflux 实现 trace-id
- c# - 获取调查 C# 中选择的用户数
- c# - ListView 在更新其屏幕后不保存更改