Skip to content

Instantly share code, notes, and snippets.

@cncolder
Created June 12, 2010 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cncolder/435240 to your computer and use it in GitHub Desktop.
Save cncolder/435240 to your computer and use it in GitHub Desktop.
//BUGFIX: Chromeframe miss some features.
(function($) {
$.oldAjax = $.ajax;
$.ajax = function(o) {
// I can't detect it by navigator.userAgent. So I set it on server side.
if (navigator.chromeframe) {
// Chromeframe can't send DELETE and PUT verb.
if (o.type == "DELETE") {
o.type = "POST";
o.data = "_method=delete";
} else if (o.type == "PUT") {
o.type = "POST";
o.data += "&_method=put";
}
}
// Chromeframe send incorrect ajax type make rails process the request by */*. The right way is JS. I try many way to avoid this. But I can do this with append .js to url only.
if (o.dataType == "script" && !/\.js$/.test(o.url)) {
o.url += ".js";
// Webkit try parse result to json then raise a syntax error when receive html. It appear in inspector only and user can't see that except u r a developer. The url(end of .js) has told rails how to process my request. So I set dataType as text because I need respondText only. I can parse json myself.
o.dataType = "text";
}
$.oldAjax(o);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment