xhrFields: jquery - ajax呼び出しでif条件を追加することは可能ですか?
元:
xhrFields : {
if(flag =='Y'){
withCredentials: true
}
}
xhrFields: jquery - ajax呼び出しでif条件を追加することは可能ですか?
元:
xhrFields : {
if(flag =='Y'){
withCredentials: true
}
}
試す:
xhrFields: {
withCredentials: flag == 'Y'
}
ただし、!='Y'のときにオプションを完全に省略する必要がある場合はflag
、次のようにすることができます。
xhrFieldsObj = {
/* You can put all the static options in here */
};
if (flag == 'Y') {
xhrFieldsObj.withCredentials = true;
};
...
xhrFields: xhrFieldsObj
var xhrFields = {};
if (flag == 'Y') {
xhrFields.withCredentials = true;
}