Skip to main content

Bug Tracker

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.

Attachments (0)
Change History (2)

Changed November 21, 2012 07:05PM UTC by dmethvin comment:1

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

Changed November 21, 2012 10:05PM UTC by dmethvin comment:2

resolution: → wontfix
status: newclosed