I'm using $.ajax() to send a string to a coldfusion server where it is stored in a table. When I later query and try to use that data I get an error; "null Enclosed Exception: Invalid byte 2 of 3-byte UTF-8 sequence".
First I grab the SVG from the DOM and send it to an action page. It should just be a string, right?
var lclSVG = $('#myDiv')[0].innerHTML; // SVG Code (XML?)
$.ajax({
url: "myAction.cfm",
type: "POST",
data: ({myInfo: lclSVG}),
});
On the myAction.cfm page I update the data into a table.
<CFQUERY NAME="postSVG">
UPDATE myTable
SET svg = '#form.myInfo#'
WHERE ID = 1
</CFQUERY>
SVG2PNG.cfm: When I attempt to query and use the svg data I get an error "Invalid byte 2 of 3-byte UTF-8 sequence". The error occurs on the .transcode line.
<CFQUERY NAME="getSVG">
SELECT svg
FROM myTable
WHERE ordID = 1
</CFQUERY>
<cfset svg = getSVG.svg>
<cfscript>
transcoder = createObject("java", "org.apache.batik.transcoder.image.PNGTranscoder").init();
inputStream = createObject("java", "java.io.StringBufferInputStream").init(svg);
input = createObject("java", "org.apache.batik.transcoder.TranscoderInput").init(inputStream);
OutFile = expandPath("myTest2.png");
outputStream=CreateObject("java", "java.io.FileOutputStream").init(OutFile);
output=CreateObject("java", "org.apache.batik.transcoder.TranscoderOutput").init(outputStream);
transcoder.transcode(input, output);
outputStream.close();
</cfscript>
I've used jQuery's ajax method several times without much difficulty. I'm doing something wrong here and I can't seem to get a handle on it...