I am trying to send a canvas.toDataUrl() to a php page via AJAX.
Here's is my try:
JavaScript code:
function showUser() {
str = "url="+canvas.toDataUrl();
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","file.php?"+str,true);
xmlhttp.send();
}
php:
<?php
$url = $_GET['url'];
echo "$url";
?>
The code above doesn't seem to be working, although I did the exact same thing but with a String value instead, like the following:
function showUser() {
str = "url=12345";
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","file.php?"+str,true);
xmlhttp.send();
}
This one works fine, but when I use canvas.toDataUrl() it doesn't work !? why?
Is there another way to send canvas.toDataUrl() to php?
Thanks