Side navigation
#12832 closed bug (wontfix)
Opened November 02, 2012 07:59AM UTC
Closed November 21, 2012 10:05PM UTC
Inconsistent handling of $.ajaxSetup between $.post with javascript data and querystring data.
Reported by: | kitsunde@gmail.com | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.6.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Run the following example: http://jsfiddle.net/kitsunde/63nBu/ and watch the network tab.
In the first case the data from ajaxSetup isn't included, in the second it is. My use case is that I was trying to setup global csrf handling for ajax requests where I was doing $.post('/', $('form').serialize()); Even though my csrf_token wasn't in the form data (it should've been, oversight on my part) it should still have included the token.
I've tested it in all versions on jsfiddle.
Honestly, don't use
$.ajaxSetup
. It's global variables at their worst in a big project. Make your own wrapper around whatever ajax functionality you need and call that to add your CSRF token. I don't think we should fix or document how every ajax option overrides or merges with ajaxSetup defaults.I created a ticket to update the docs: https://github.com/jquery/api.jquery.com/issues/179