Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce264e0

Browse files
authored
Ajax: AllowprocessData: true even for binary data
The waygh-5197 implemented binary data handling, `processData`was being explicitly set to `false`. This is expected but it madeit impossible to override it to `true`. The new logic will onlyset `processData` to `false` if it wasn't explicitly passedin original options.Closesgh-5205Refgh-5197
1 parentcff2899 commitce264e0

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

‎src/ajax/binary.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ import jQuery from "../core.js";
22

33
import"../ajax.js";
44

5-
jQuery.ajaxPrefilter(function(s){
5+
jQuery.ajaxPrefilter(function(s,origOptions){
66

77
// Binary data needs to be passed to XHR as-is without stringification.
8-
if(typeofs.data!=="string"&&!jQuery.isPlainObject(s.data)){
8+
if(typeofs.data!=="string"&&!jQuery.isPlainObject(s.data)&&
9+
10+
// Don't disable data processing if explicitly set by the user.
11+
!("processData"inorigOptions)){
912
s.processData=false;
1013
}
1114

‎test/unit/ajax.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,4 +3148,27 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
31483148
};
31493149
});
31503150

3151+
ajaxTest("jQuery.ajax() - non-plain object",1,function(assert){
3152+
return{
3153+
url:url("mock.php?action=name"),
3154+
method:"post",
3155+
data:Object.create({name:"peter"}),
3156+
success:function(data){
3157+
assert.strictEqual(data,"ERROR","Data correctly not sent");
3158+
}
3159+
};
3160+
});
3161+
3162+
ajaxTest("jQuery.ajax() - non-plain object with processData: true",1,function(assert){
3163+
return{
3164+
url:url("mock.php?action=name"),
3165+
method:"post",
3166+
processData:true,
3167+
data:Object.create({name:"peter"}),
3168+
success:function(data){
3169+
assert.strictEqual(data,"pan","Data sent correctly");
3170+
}
3171+
};
3172+
});
3173+
31513174
})();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp