jQuery的阿贾克斯似乎改变发送到ColdFusion服务器的SVG数据 [英] jQuery ajax seems to alter SVG data sent to coldfusion server

查看:226
本文介绍了jQuery的阿贾克斯似乎改变发送到ColdFusion服务器的SVG数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用$阿贾克斯()发送一个字符串,它被存储在一个表中的ColdFusion服务器。当我后来查询并尝试使用这些数据我得到一个错误; 空封闭式例外:3个字节的UTF-8序列无效字节2。

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的错误。在.trans code线出现的错误。

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...

推荐答案

几件事情:

  1. 我假设你的存储SVG在UTF-8兼容领域?
  2. 您能否证实从DOM抓住它后发布前的SVG是正确的?
  3. 在您的ColdFusion管理员,去你的数据源设置,然后单击显示高级设置。确保标有启用配置的非拉丁字符的数据源高ASCII字符和统一code的复选框被选中。

这篇关于jQuery的阿贾克斯似乎改变发送到ColdFusion服务器的SVG数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆