The source code below is used to create a picture box with some image captured by a camera. Using toDataURL, a base64 string is send to a server written in Golang. The issue I’m facing is that sometimes the previous picture or a black picture is send. Seems some async issue or so. Does anyone has a clue? The program is transferred using PhoneGap to Android.
// get picture from URL into picture box
pb = PictureBox1.getContext("2d");
pb.addImage(photo_url,0,0,PictureBox1.width, PictureBox1.height);
// make url
url = "/abc/v1/storephoto1/key";
// send base64 string of picturebox content
req = Ajax( url, "POST" , PictureBox1.toDataURL("image/jpeg"));