Search code examples
mysqlajaxhtmlcanvasdata-url

pass a dataURL through AJAX


I'm attempting to save a dataURL made from an HTML5 canvas to my mysql db.

I have ajax setup to pull the var I've made called "dataURL" and I'm setting dataURL to the canvas's img using this code:

dataURL = oCanvas.toDataURL();

my issue is the canvas's dataURL has alot of characters that don't work well in pulling for ajax so I need a way to encode it or manipulate it differently so my end result can be saved to a mysql db and then later "decoded" to display once again.

I know my AJAX works because if I set the var dataURL to something like "cheese" it saves in the database as cheese.

Any help would be much appreciated!


Solution

  • I actually ended up setting an event so when the image was done drawing it would set the dataURL to a hidden form element. No longer needed to pass it through ajax :). Thanks for the suggestion though.