Browse files

Merge pull request #126 from mborho/master

Additional parameter for enyo.Ajax added to override the MIME-Type

Enyo-DCO-1.0-Signed-off-by: Martin Borho (martin@borho.net)
Reviewed-By: Ben Combee (ben.combee@palm.com)
  • Loading branch information...
2 parents f859707 + 328e30f commit 37ef3fee9540d70bf6971345046560400ce12606 @unwiredben unwiredben committed Aug 2, 2012
Showing with 14 additions and 4 deletions.
  1. +4 −3 source/ajax/Ajax.js
  2. +5 −1 source/ajax/AjaxProperties.js
  3. +5 −0 source/ajax/xhr.js
View
7 source/ajax/Ajax.js
@@ -1,12 +1,12 @@
/**
_enyo.Ajax_ is a wrapper for _XmlHttpRequest_ that uses
the <a href="#enyo.Async">enyo.Async</a> API.
-
+
IMPORTANT: _enyo.Ajax_ publishes all the properties of the
<a href="#enyo.AjaxProperties">enyo.AjaxProperties</a>
object.
- Like _enyo.Async_, _enyo.Ajax_ is an **Object**, not a **Component**.
+ Like _enyo.Async_, _enyo.Ajax_ is an **Object**, not a **Component**.
Do not try to make _enyo.Ajax_ objects inside a _components_ block.
If you want to use _enyo.Ajax_ as a component, you should probably
@@ -83,7 +83,8 @@ enyo.kind({
sync: window.PalmSystem ? false : this.sync,
username: this.username,
password: this.password,
- xhrFields: this.xhrFields
+ xhrFields: this.xhrFields,
+ mimeType: this.mimeType
});
},
receive: function(inText, inXhr) {
View
6 source/ajax/AjaxProperties.js
@@ -47,5 +47,9 @@ enyo.AjaxProperties = {
/**
Optional object with fields to pass directly to the underlying XHR object.
*/
- xhrFields: null
+ xhrFields: null,
+ /**
+ Optional string to override the MIME-Type.
+ */
+ mimeType: null
};
View
5 source/ajax/xhr.js
@@ -11,6 +11,7 @@ enyo.xhr = {
- _username_: The optional user name to use for authentication purposes.
- _password_: The optional password to use for authentication purposes.
- _xhrFields_: Optional object containing name/value pairs to mix directly into the generated xhr object.
+ - _mimeType_: Optional string to override the MIME-Type.
*/
request: function(inParams) {
var xhr = this.getXMLHttpRequest();
@@ -33,6 +34,10 @@ enyo.xhr = {
}
}
//
+ if(typeof(xhr.overrideMimeType) == "function" && inParams.mimeType) {
+ xhr.overrideMimeType(inParams.mimeType);
+ }
+ //
xhr.send(inParams.body || null);
if (!async) {
xhr.onreadystatechange(xhr);

0 comments on commit 37ef3fe

Please sign in to comment.