Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#8219 closed bug (fixed)

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
Blocked by: Blocking:

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 (8)

comment:1 Changed 13 years ago by jitter

Component: unfiledajax
Owner: set to curiousdannii
Priority: undecidedlow
Status: newpending

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 13 years ago by curiousdannii

Status: pendingnew

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 13 years ago by curiousdannii (previous) (diff)

comment:3 Changed 13 years ago by jitter

Cc: jaubourg added

comment:4 Changed 13 years ago by jaubourg

Keywords: regression added
Milestone: 1.next1.5.1
Owner: changed from curiousdannii to jaubourg
Status: newassigned

comment:5 Changed 13 years ago by jaubourg

Resolution: fixed
Status: assignedclosed

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 13 years ago by jaubourg

Keywords: needsdocs added

dannii, can you confirm this fixes your issue?

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

comment:7 Changed 13 years ago by curiousdannii

Works great, thanks!

comment:8 Changed 12 years ago by addyosmani

Keywords: neededdocs added; regression needsdocs removed

The docs for this have been updated.

Note: See TracTickets for help on using tickets.