jQuery ajax seems to alter SVG data sent to coldfusion server(jQuery ajax 似乎改变了发送到coldfusion服务器的SVG数据)
问题描述
我正在使用 $.ajax() 将字符串发送到存储在表中的coldfusion 服务器.当我稍后查询并尝试使用该数据时,我得到一个错误;null Enclosed Exception: Invalid byte 2 of 3-byte UTF-8 sequence".
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".
首先,我从 DOM 中获取 SVG 并将其发送到操作页面.它应该只是一个字符串,对吧?
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}),
});
在 myAction.cfm 页面上,我将数据更新到表格中.
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:当我尝试查询和使用 svg 数据时,我收到错误3 字节 UTF-8 序列的字节 2 无效".错误发生在 .transcode 行.
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>
我已经多次使用 jQuery 的 ajax 方法,没有太大的困难.我在这里做错了,我似乎无法处理它......
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...
推荐答案
几件事:
- 我假设您将 SVG 存储在与 UTF-8 兼容的字段中?
- 您能否在从 DOM 中获取 SVG 并在发布之前确认它是正确的?
- 在您的 ColdFusion 管理员中,转到您的数据源设置并单击显示高级设置".确保选中标有为配置为非拉丁字符的数据源启用高位 ASCII 字符和 Unicode"的框.
这篇关于jQuery ajax 似乎改变了发送到coldfusion服务器的SVG数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:jQuery ajax 似乎改变了发送到coldfusion服务器的SVG数


- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Fetch API 如何获取响应体? 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06