Bug Tracker

Opened 10 years ago

Closed 10 years ago

#12832 closed bug (wontfix)

Inconsistent handling of $.ajaxSetup between $.post with javascript data and querystring data.

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:


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.

Change History (2)

comment:1 Changed 10 years ago by dmethvin

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

comment:2 Changed 10 years ago by dmethvin

Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.