aboutsummaryrefslogtreecommitdiffstats
path: root/src/ajax/binary.js
blob: 96fc5a469e0c1cb8b832768aaf17973abd7a1b1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { jQuery } from "../core.js";

import "../ajax.js";

jQuery.ajaxPrefilter( function( s, origOptions ) {

	// Binary data needs to be passed to XHR as-is without stringification.
	if ( typeof s.data !== "string" && !jQuery.isPlainObject( s.data ) &&
			!Array.isArray( s.data ) &&

			// Don't disable data processing if explicitly set by the user.
			!( "processData" in origOptions ) ) {
		s.processData = false;
	}

	// `Content-Type` for requests with `FormData` bodies needs to be set
	// by the browser as it needs to append the `boundary` it generated.
	if ( s.data instanceof window.FormData ) {
		s.contentType = false;
	}
} );