Created
June 21, 2010 15:44
-
-
Save rpheath/447042 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
| // Why is this not working in IE!?!? | |
| // (using jQuery 1.4.2 and Rails 2.3.5) | |
| // The issue is that it either: 1) posts as a regular form, ignoring the ajax | |
| // or 2) asks me to download a file | |
| // Yes, I've tried config.action_controller.use_accept_header = false | |
| // in environment.rb and that has no effect on the outcome | |
| // force accept headers | |
| $.ajaxSetup({ | |
| 'beforeSend': function(xhr) { | |
| xhr.setRequestHeader('Accept', 'text/javascript') | |
| } | |
| }) | |
| // the plugin | |
| $.fn.submitWithAjax = function() { | |
| this.live('submit', function(e) { | |
| e.preventDefault() | |
| $.post(this.action + ".js", $(this).serialize(), null, "script") | |
| }) | |
| } | |
| // initialize ajax forms | |
| $('div.ajax form').submitWithAjax() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment