Add correct Content-Type when ajax:beforeSend sets data.#119
Closed
Confiscative wants to merge 1 commit intorails:masterfrom
Closed
Add correct Content-Type when ajax:beforeSend sets data.#119Confiscative wants to merge 1 commit intorails:masterfrom
Confiscative wants to merge 1 commit intorails:masterfrom
Conversation
…Type if data is provided in the 'ajax:beforeSend' event.
|
With this commit 5b23c3d now you have a before callback which is fired before the beforeSend is activated. I think this might help you tackle your problem in a nicer way. Do you still think this pull request should be merged? |
Author
|
The 'before'-fix you proposed seems like a better solution indeed. I'll close this one down then. |
|
The ajax:before solution still only works if you have a form. If you are using a link to generate an ajax request and want to attach data to the request before it goes out, there is no clean way of doing it. If you do it in ajax:beforeSend, you then have to manually set the Content-Type header for the xhr request. |
This pull request was closed.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This modification allows to unobtrusively add data to remote POST or PUT tags that aren't forms via the ajax:beforeSend event. Normally when data is provided the Content-Type is set internally by jQuery, but this happens before the beforeSend callback has been handled (line 6707, jQuery v1.5.1).
Example: