Skip to content

Commit

Permalink
Fix for requesting remote data with the correct data type format
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.dojotoolkit.org/src/dojox/trunk@22476 560b804f-0ae3-0310-86f3-f6aa0a117693
  • Loading branch information
foobarfighter committed Jul 14, 2010
1 parent ec24b7b commit 71643e9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion rails.js
Expand Up @@ -52,6 +52,15 @@ dojo.ready((function(d, dr, dg){
});
};

var typeMap = {
"text": "text",
"json": "application/json",
"json-comment-optional": "text",
"json-comment-filtered": "text",
"javascript": "application/javascript",
"xml": "text/xml"
};

var handleRemote = function(evt){
var el = evt.target, tag = el.tagName.toLowerCase();
var content = tag.toLowerCase() == "form" ? d.formToObject(el) : {},
Expand All @@ -65,11 +74,12 @@ dojo.ready((function(d, dr, dg){
}
evt.preventDefault();


// ajax:loading, ajax:loaded, and ajax:interactive are not supported
d.publish("ajax:before", [el]);
var deferred = d.xhr(method, {
url: url,
headers: { "Accept": type == "text" ? "text" : "text/"+type },
headers: { "Accept": typeMap[type] },
content: content,
handleAs: type,
load: function(response, ioArgs) {d.publish("ajax:success", [el, response, ioArgs]);},
Expand Down

0 comments on commit 71643e9

Please sign in to comment.