Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //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);
- };
- });
Add Comment
Please, Sign In to add comment