-
Notifications
You must be signed in to change notification settings - Fork 83
Replace 'ajax_caller.js' with JavaScript implementation #2401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We can attempt to implement the following:
|
We should test the following snippet: ...
}).then(function(response) {
if (response.ok) {
// asynchronous callback
callbackDone(response);
} else {
// define error
var error = new Error(response.statusText);
error.response = response;
throw error;
}
}, function(error) {
// asynchronous callback
callbackFail(error.message, error.response);
});
... Specifically, we should test if we can create an arbitrary ...
}).fail(function(jqXHR, textStatus, errorThrown) {
// asynchronous callback
callbackFail(textStatus, errorThrown);
});
... |
We implemented two uncommitted ...
// send form data to serverside on form submission
handleSubmit: function(event) {
// prevent page reload
event.preventDefault();
// local variables
var sessionType = this.state.value_session_type;
if (
sessionType == 'data_new' || sessionType == 'data_append' ||
sessionType == 'model_generate' || sessionType == 'model_predict'
) {
var ajaxEndpoint = '/load-data/';
var ajaxArguments = {
'endpoint': ajaxEndpoint,
'data': new FormData(this.refs.svmForm),
'contentType': false,
'processData': false,
};
console.log(this.refs.svmForm);
console.log(ajaxArguments.data);
// boolean to show ajax spinner
this.setState({display_spinner: true});
// asynchronous callback: ajax 'done' promise
ajaxCaller(function (asynchObject) {
// Append to DOM
if (asynchObject && asynchObject.error) {
this.setState({ajax_done_error: asynchObject.error});
} else if (asynchObject) {
this.setState({ajax_done_result: asynchObject});
}
else {
this.setState({ajax_done_result: null});
}
// boolean to hide ajax spinner
this.setState({display_spinner: false});
}.bind(this),
// asynchronous callback: ajax 'fail' promise
function (asynchStatus, asynchError) {
if (asynchStatus) {
this.setState({ajax_fail_status: asynchStatus});
console.log('Error Status: ' + asynchStatus);
}
if (asynchError) {
this.setState({ajax_fail_error: asynchError});
console.log('Error Thrown: ' + asynchError);
}
// boolean to hide ajax spinner
this.setState({display_spinner: false});
}.bind(this),
// pass ajax arguments
ajaxArguments);
}
},
... However, the Note: we've created a parallel issue to acquire additional input, regarding our implementation of fetch. |
We checked out the ...
// send form data to serverside on form submission
handleSubmit: function(event) {
// prevent page reload
event.preventDefault();
// local variables
var sessionType = this.state.value_session_type;
if (
sessionType == 'data_new' || sessionType == 'data_append' ||
sessionType == 'model_generate' || sessionType == 'model_predict'
) {
var ajaxEndpoint = '/load-data/';
var ajaxArguments = {
'endpoint': ajaxEndpoint,
'data': new FormData(this.refs.svmForm),
'contentType': false,
'processData': false,
};
console.log(this.refs.svmForm);
console.log(ajaxArguments.data);
// boolean to show ajax spinner
this.setState({display_spinner: true});
// asynchronous callback: ajax 'done' promise
ajaxCaller(function (asynchObject) {
// Append to DOM
if (asynchObject && asynchObject.error) {
this.setState({ajax_done_error: asynchObject.error});
} else if (asynchObject) {
this.setState({ajax_done_result: asynchObject});
}
else {
this.setState({ajax_done_result: null});
}
// boolean to hide ajax spinner
this.setState({display_spinner: false});
}.bind(this),
// asynchronous callback: ajax 'fail' promise
function (asynchStatus, asynchError) {
if (asynchStatus) {
this.setState({ajax_fail_status: asynchStatus});
console.log('Error Status: ' + asynchStatus);
}
if (asynchError) {
this.setState({ajax_fail_error: asynchError});
console.log('Error Thrown: ' + asynchError);
}
// boolean to hide ajax spinner
this.setState({display_spinner: false});
}.bind(this),
// pass ajax arguments
ajaxArguments);
}
},
... which generated the following output within the |
We need to implement the following methods, to check whether respective components have mounted: ...
componentDidMount() {
this.mounted = true;
}
componentWillUnmount() {
this.mounted = false;
}
... then, we can check Note: this comment was inspired by the following |
Our above attempt to resolve the following bug was not successful:
Therefore, we will proceed by opening a dedicated issue to further debug, and resolve the latter bug. This will allow us to return to the main focus of this issue, which currently does not allow dynamic |
If we adjust ...
// ajax logic
fetch(args.endpoint, {
method: 'post',
body: args.data,
headers: {
'Accept': 'text/javascript'
}
... by defining ...
// ajax logic
fetch(args.endpoint, {
method: 'post',
body: args.data,
headers: {
'Accept': 'text/javascript',
'Content-Type': args.contentType
}
... the
So, we need to find a default ...
// set the contentType
if (args.contentType === null) {
args.contentType = 'some/value';
}
// ajax logic
fetch(args.endpoint, {
method: 'post',
body: args.data,
headers: {
'Accept': 'text/javascript',
'Content-Type': args.contentType
}
... |
#2401: Replace 'ajax_caller.js' with JavaScript implementation
We forgot to include changes in |
#2401: views.py, properly acquire 'session_id'
We will replace our jquery implementation of
ajax_caller.js
, with a pure javascript implementation. Then, we will removejquery-2.1.1.js
, and ensure 80 character limitation by our jshint, and jscs implementations.The text was updated successfully, but these errors were encountered: