reactjs - how to cancel/abort ajax request in axios -
i use axios
ajax requests , reactjs
+ flux
render ui. in app there third side timeline (reactjs component). timeline can managed mouse's scroll. app sends ajax request actual data after scroll event. problem processing of request @ server can more slow next scroll event. in case app can have several (2-3 usually) requests deprecated because user scrolls further. problem because every time @ receiving of new data timeline begins redraw. (because it's reactjs + flux) because of this, user sees movement of timeline , forth several times. easiest way solve problem, abort previous ajax request in jquery
. example:
$(document).ready( var xhr; var fn = function(){ if(xhr && xhr.readystate != 4){ xhr.abort(); } xhr = $.ajax({ url: 'ajax/progress.ftl', success: function(data) { //do } }); }; var interval = setinterval(fn, 500); );
how cancel/abort requests in axios
?
axios not support canceling requests @ moment. please see this issue details.
update: cancellation support added in axios v0.15.
Comments
Post a Comment