Created
June 12, 2010 00:28
-
-
Save cncolder/435240 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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