0

「accept-charset='utf-8'」を使用して SVG データをアクション ページに投稿しています。アクション ページで、そのデータをテーブルに挿入しています。その後、別のページで、そのデータをテーブルからクエリし、Batik で実行して PNG ファイルにトランスコードします。それはうまくいきます。

<form action="test_action.cfm" method="post" target="_blank" accept-charset="utf-8">

form タグから accept-charset="utf-8" を削除すると、後で (トランスコード ページで) 「3 バイト UTF-8 シーケンスのバイト 2 が無効です」というエラーが表示されます (トランスコードしようとすると)。

さらに、jQuery の .ajax() を使用してバックグラウンドでアクション ページを処理しようとするたびに、まったく同じエラーが発生します。「accept-charset="utf-8"」を使用すると、すべて機能します。

$.ajax() を使用して、SVG をバックグラウンドでアクション ページに送信しようとします。

var lclSVG = $('#myDiv')[0].innerHTML;
$.ajax({
  url: "myAction.cfm",
  type: "POST",
  data: ({myInfo: lclSVG}),
});

.ajax() に「accept-charset="utf-8"」のようなことを強制しながら、$.ajax() 経由でこのデータを投稿する方法はありますか?

4

1 に答える 1

0

According to the JQuery ajax() docs, the default already is UTF-8. But maybe try to foce the setting anyhow, as per those docs, with the contentType option. You might also want to look at the processData option, as it specifically mentions XML handling.

I agree with your analysis, but have you verified that the corruption is occurring during the upload process, or some quirk to do with your transcoding (more details against this question): perhaps things are running slightly different between your normal file upload and your AJAX upload?

To eliminate this, rather than processing right through to transcoding, maybe just write the data to an SVG and test it before trying the transcoding (just as a troubleshooting step, I mean).

You might get some more hints as to what's going on by using Firebug to look at the request to the server that sends the file: compare the two approaches and look for differences.

Not an explicit answer, I'm afraid, but perhaps some stuff to look at.

于 2012-11-04T11:07:16.590 に答える