Cancel asynchronous

Development tools and key technologies: vs, MVC
Author: Chen Xingyu
wrote Time: April 13

About asynchronous submission, we are already familiar with is also very convenient, but we have to face some situations to use synchronous submitted
when we use the number of recorded data when the asynchronous sequential has often make our data anomalies
we declare two variable data records
Here Insert Picture Description
then we can view the page by step code breakpoints
Firstly, our page
Here Insert Picture Description
is to jump if statement to judge
conditions are not met to jump directly to the next step, but the next step is not to jump to get in our submission , jump directly to the following statement to determine if the number of records directly to our records
Here Insert Picture Description
at this time if the statement ckdata.length a value of 1 and we declare the Return, the numerical count of zero, this time if it does not meet conditions Article else's statement to prompt data anomalies
and then jump before we write of data to be submitted in an asynchronous get
self plus one pair Return statement in the callback function
Here Insert Picture Description
condition behind this time, if only to satisfy the condition statement and its code has been run over
when this happens, we have to use synchronous commit, simply, is to cancel asynchronous
Here Insert Picture Description
When we cancel asynchronous, synchronous operation, the code will be executed by sequential go
get the effect we want to record data of the
Here Insert Picture Description
above is a cancel asynchronous, synchronous achieve a case submitted

Guess you like

Origin blog.csdn.net/tianxiu11/article/details/89299156
Recommended