When JavaScript implements an Ajax request, the page displays the effect of waiting. After the specified request time is exceeded, other operations are performed.

  Background: There is a button that initiates an Ajax request to the backend program after clicking it. Before the request result is returned, the page displays the effect of waiting. At this time, it is still an asynchronous request, and the effect of waiting is cancelled after receiving the result.

  Requirement: Due to network delay or back-end program problems, after an Ajax request is initiated, it may not receive data after waiting for 10s. What needs to be done now is, if the waiting time exceeds 10s, the user will be prompted to perform other operations, no need to continue. Wait for the result and terminate the operation after Ajax gets the data, that is, it is considered that Ajax will never get the data.

  solution:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324842819&siteId=291194637