how to abort an ajax request once the browser receive 200ok
i have an ajax request that looks like
- // ---------------------------------------- start(clicked_button, app_path)
- var start = function(clicked_button, app_path) {
-
- $.ajax({
- type: 'POST',
- data: { 'app_path': app_path },
- url: '/app/start',
- context: clicked_button,
-
- success: function(msg) {console.log('ok go to sleep ..'); }
- })
-
- .done(function(data) {
- console.log(data);
- $(this).removeClass('btn-success');
- $(this).addClass('btn-danger');
- $(this).text('stop');
- })
-
- .fail(function(data) {
- console.log('failed to start the app: ' + data);
- })
- };
the request is completed successfuly, and the operation is done i expect it to be, the browser receive a 200 ok from the server, but .done() is not triggered, i have no idea way?
all i want is just abort the request once the browser receive a 200 ok, so how can i do that?