jQuery.ajax和图像数据编码 [英] jQuery.ajax and image data encoding

查看:172
本文介绍了jQuery.ajax和图像数据编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图获取通过AJAX,已经使用InkFilePicker上传存储在S3中的图像。 InkFilePicker有一个方法叫做filepicker.read(),它可用于从图像读取的原始数据。然而,这是相当有限的,所以我想用jQuery.ajax()来代替。但似乎他们不返回完全相同的数据。

I'm trying to fetch an image stored at S3, via AJAX, which has been uploaded using InkFilePicker. InkFilePicker has a method called filepicker.read() which can be used to read the raw data from an image. However, it's quite limited so I want to use jQuery.ajax() instead. But it seems that they don't return exactly the same data.

中的数据时,它记录到控制台时使用filepicker.read()看起来是这样的:

The data received when using filepicker.read() looks like this when logging it to the console:

在使用jQuery.ajax(),它看起来是这样的:

When using jQuery.ajax() it looks like this:

在使用由jQuery.ajax()我的其他脚本似乎打破(我提取EXIF数据),返回的数据。

When using the data returned by jQuery.ajax() my other scripts seems to break (I'm extracting the EXIF data).

那么,为什么它显得与众不同呢?请问jQuery的尝试连接Ç不知何故数据code /德$ C $?我能prevent呢?

So, why does it look different at all? Does jQuery try to encode/decode the data somehow? Can I prevent that?

推荐答案

好吧,我不得不将它添加到<一个href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHtt$p$pquest/Using_XMLHtt$p$pquest#Handling_binary_data"相对=nofollow>覆盖MIMETYPE 出于某种原因...

Ok, I had to add this to override the mimetype for some reason...

$.ajax({
...
  beforeSend: function(xhr) {
      xhr.overrideMimeType( "text/plain; charset=x-user-defined" )
  }
...
})

这篇关于jQuery.ajax和图像数据编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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