Skip to main content

Bug Tracker

Side navigation

#8219 closed bug (fixed)

Opened February 09, 2011 10:09AM UTC

Closed February 09, 2011 04:51PM UTC

Last modified March 09, 2012 11:32AM UTC

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.

Attachments (0)
Change History (8)

Changed February 09, 2011 11:35AM UTC by jitter comment:1

component: unfiledajax
owner: → 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

Changed February 09, 2011 12:17PM UTC by curiousdannii comment:2

_comment0: 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.1297254182074030
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://.

Changed February 09, 2011 02:34PM UTC by jitter comment:3

cc: → jaubourg

Changed February 09, 2011 04:13PM UTC by jaubourg comment:4

keywords: → regression
milestone: 1.next1.5.1
owner: curiousdanniijaubourg
status: newassigned

Changed February 09, 2011 04:51PM UTC by jaubourg comment:5

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

Changed February 09, 2011 04:52PM UTC by jaubourg comment:6

_comment0: dannii, can you confirm this fixe your issue?1297270545156500
keywords: regressionregression, needsdocs

dannii, can you confirm this fixes your issue?

Changed February 09, 2011 10:10PM UTC by curiousdannii comment:7

Works great, thanks!

Changed June 16, 2011 05:15AM UTC by addyosmani comment:8

keywords: regression, needsdocsneededdocs

The docs for this have been updated.