Bug Tracker

Modify

Ticket #8219 (closed bug: fixed)

Opened 3 years ago

Last modified 2 years ago

Reversion: overrideMimeType() no longer callable

Reported by: curiousdannii Owned by: jaubourg
Priority: low Milestone: 1.5.1
Component: ajax Version: 1.5
Keywords: neededdocs Cc: jaubourg
Blocking: Blocked by:

Description

Before 1.4 we could call overrideMimeType() in beforeSend(). It had many uses, mine being for changing the charset for binary access.

In 1.5 beforeSend is only passed a jqXHR object so this is no longer possible.

Neither does the XHR transport provide any hooks where I could call overrideMimeType().

A work around would be to duplicate the whole transport. I'd rather not do that if it could be avoided.

Change History

comment:1 Changed 3 years ago by jitter

  • Owner set to curiousdannii
  • Priority changed from undecided to low
  • Status changed from new to pending
  • Component changed from unfiled to ajax

Thanks for taking the time to contribute to the jQuery project by writing a bug report.

After checking your report I'm not sure how this is a problem. overrideMimeType() is not in the XMLHttpRequest specification (not until Level 2). And there is no cross-browser support for this method anyway (IE 6,7,8 !!).

I'm also not sure why you would use this method when you are using jQuery.ajax(). As from my understanding you can accomplish the same behavior by setting the dataType option. I'm not even sure calling this function had any influence on the way jQuery worked.

So lease submit a reduced test case, which produces the issue you are experiencing, on  http://jsfiddle.net. In order to enable us to investigate this issue further. Also make sure to read the link given below, in order to provide a most useful bug report.


 How to report bugs

comment:2 Changed 3 years ago by curiousdannii

  • Status changed from pending to new

Test cases: 1.4:  http://jsfiddle.net/YcMvd/3/ 1.5:  http://jsfiddle.net/6XMZq/

In 1.4 the test case will log twice, showing the importance of the override. In 1.5 it throws an error. Which is to be expected considering it's no longer actually passed the XHR.

dataType doesn't seem to be relevant. It sets the accepts header but that doesn't actually change what content-type is sent from the server, nor does it support setting encodings. You can't overwrite it after it's been received either. That's what overrideMimeType() is for.

For IE and Opera < 10.5 (which had a broken overrideMimeType()) I fallback to using a proxy and deliver the data base64 encoded. But that is to be avoided for many reasons, such as not working for  file://.

Last edited 3 years ago by curiousdannii (previous) (diff)

comment:3 Changed 3 years ago by jitter

  • Cc jaubourg added

comment:4 Changed 3 years ago by jaubourg

  • Keywords regression added
  • Owner changed from curiousdannii to jaubourg
  • Status changed from new to assigned
  • Milestone changed from 1.next to 1.5.1

comment:5 Changed 3 years ago by jaubourg

  • Status changed from assigned to closed
  • Resolution set to fixed

Fixes #8219. Introduces the mimeType option to override content-type header in conversion (and in native xhr when possible). Adds companion overrideMimeType method on jqXHR object (it simply sets the option). Unit test added.

Changeset: f6e173437e9f94cd4e713e556c6fc8ca68be8384

comment:6 Changed 3 years ago by jaubourg

  • Keywords regression, needsdocs added; regression removed

dannii, can you confirm this fixes your issue?

Last edited 3 years ago by jaubourg (previous) (diff)

comment:7 Changed 3 years ago by curiousdannii

Works great, thanks!

comment:8 Changed 3 years ago by addyosmani

  • Keywords neededdocs added; regression, needsdocs removed

The docs for this have been updated.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.