简体   繁体   中英

jQuery.ajax and image data encoding

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.

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

来自filepicker.read()的数据

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

来自jQuery.ajax()的数据

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

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

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" )
  }
...
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM