Skip to content

Commit 14ed881

Browse files
authored
[dqt] Replace jQuery ajax calls with fetch in DQT (#8396)
This replaces all the jQuery ajax calls with fetch in the files modules/dqt/jsx/react.fieldselector.js and modules/dqt/jsx/react.filterBuilder.js.
1 parent a7aef68 commit 14ed881

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

modules/dqt/jsx/react.fieldselector.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,15 +426,19 @@ class FieldSelector extends Component {
426426
if (this.state.categoryFields[category]) {
427427
} else {
428428
// Retrieve the data dictionary
429-
$.get(loris.BaseURL
430-
+ '/AjaxHelper.php?Module=dqt&script=datadictionary.php',
431-
{category: category}, (data) => {
429+
fetch(loris.BaseURL
430+
+ '/AjaxHelper.php'
431+
+ '?Module=dqt'
432+
+ '&script=datadictionary.php'
433+
+ '&category=' + category)
434+
.then((resp) => resp.json())
435+
.then( (data) => {
432436
let cf = this.state.categoryFields;
433437
cf[category] = data;
434438
this.setState({
435439
categoryFields: cf,
436440
});
437-
}, 'json');
441+
});
438442
}
439443
this.setState({
440444
selectedCategory: category,

modules/dqt/jsx/react.filterBuilder.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,16 @@ class FilterRule extends Component {
120120
let rule = this.props.rule;
121121
if (event.target.value) {
122122
rule.instrument = event.target.value;
123-
$.get(loris.BaseURL
124-
+ '/dqt/ajax/datadictionary.php',
125-
{category: rule.instrument}, (data) => {
123+
fetch(
124+
loris.BaseURL + '/dqt/ajax/datadictionary.php?category='
125+
+ rule.instrument,
126+
{credentials: 'same-origin'},
127+
)
128+
.then( (resp) => resp.json())
129+
.then( (data) => {
126130
rule.fields = data;
127131
this.props.updateRule(this.props.index, rule);
128-
}, 'json');
132+
});
129133
}
130134
}
131135

@@ -223,15 +227,16 @@ class FilterRule extends Component {
223227
this.props.updateSessions(this.props.index, rule);
224228
};
225229
let ajaxRetrieve = (script) => {
226-
$.get(loris.BaseURL + '/dqt/ajax/' + script,
227-
{
228-
category: rule.instrument,
229-
field: rule.field,
230-
value: this.state.value,
231-
},
232-
responseHandler,
233-
'json',
234-
);
230+
fetch(loris.BaseURL + '/dqt/ajax/' + script
231+
+ '?category=' + rule.instrument
232+
+ '&field=' + rule.field
233+
+ '&value=' + this.state.value,
234+
{credentials: 'same-origin'},
235+
)
236+
.then( (resp) => resp.json())
237+
.then( (data) => {
238+
responseHandler(data);
239+
});
235240
};
236241
switch (rule.operator) {
237242
case 'equal':

0 commit comments

Comments
 (0)