网页端生成小程序码图片显示
直接看代码
var xmlhttp;
xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", ajaxUrl.getCode, true);
xmlhttp.responseType = "arraybuffer";
xmlhttp.onreadystatechange = function () {
if (this.status == 200) {
var imageType = xmlhttp.getResponseHeader("Content-Type");
var blob = new Blob([xmlhttp.response], { type: imageType });
var imageUrl = (window.URL || window.webkitURL).createObjectURL(blob);
$('#image').attr("src", imageUrl);
}
}
var formData = new FormData();
formData.append('url', 'xxx');
formData.append('scene', 'id=xxx');
xmlhttp.send(formData)