这是我的代码:
html2canvas([document.getElementById('myCanvas')],
{
onrendered: function(canvas)
{
$.post('save.php',
{
data: canvas.toDataURL('image/jpeg')
},
function (file)
{
window.location.href = 'download.php?path='+ file
});
}
});
当我使用PHP $_POST['data']
执行它时; ,它给了我一个错误:未定义的索引:数据
如何获取数据并将其存储在PHP变量中?谢谢!
答案 0 :(得分:2)
试试这个
html2canvas([document.getElementById('myCanvas')],
{
onrendered: function(canvas)
{
$.post('save.php',
{
data: {
"Param1":canvas.toDataURL('image/jpeg')
}
},
function (file)
{
window.location.href = 'download.php?path='+ file
});
}
});
在PHP函数中使用
获取变量$_POST['Param1']