Home > Web Front-end > JS Tutorial > Briefly describe the execution sequence of jQuery ajax_jquery

Briefly describe the execution sequence of jQuery ajax_jquery

WBOY
Release: 2016-05-16 15:21:40
Original
1607 people have browsed it

The default async of Ajax in jQuery is true (asynchronous request). If you want to execute another Ajax after one Ajax is executed, you need to set async=false.

The code is as follows:

function TestAjax()
{
 var UserName = $("#txtUserName").val();
 $.ajax({
  url:"AjaxCheckUserName.htm",
  async:false,
  success:function(data){
   alert(data);
  }
 });
 alert('Test');
 $.ajax({
  url:"AjaxHandler.ashx",
  async:false,
  data:"UserName=" + UserName,
  success:function(data){
   $("#divAjax").html(data);
  },
  error:function(msg){
   alert(msg.responseText);
  }
 });
}
Copy after login

Then take a look at the execution sequence of each jquery $.ajax event

The execution sequence is as follows:

1.ajaxStart (global event)

2.beforeSend

3.ajaxSend (global event)

4.success

5.ajaxSuccess (global event)

6.error

7.ajaxError (global event)

8.complete

9.ajaxComplete (global event)

10.ajaxStop (global event)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template