ajax ajaxStart() method


  Translation results:

Ajax

English [ˈeɪˌdʒæks] American [ˈeˌdʒæks]

n. The full name is "Asynchronous JavaScript and XML" (asynchronous JavaScript and XML); refers to a A web development technology for creating interactive web applications. ;Ajax copper-tin-lead bearing alloy, Ajax explosives

start

UK[stɑ:t] US[stɑ:rt]

n.Start; set off; start; starting point

vt.& vi. Set off, set off

vt.Start; raise (question); start; start

vi .Start; appear suddenly; suddenly jump up; suddenly surge out

ajax ajaxStart() methodsyntax

Function: ajaxStart() method executes the function before the AJAX request is sent. It is an Ajax event.

Syntax: .ajaxStart(function())

Description: Whenever an Ajax request is sent, jQuery will check whether There are other Ajax requests. If it doesn't exist, jQuery fires the ajaxStart event. At this point, any functions registered by the .ajaxStart() method will be executed.

Parameters:

Parameter Description
function ()Specifies the function to be run when an AJAX request starts.

ajax ajaxStart() methodexample

<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("div").ajaxStart(function(){
    $(this).html("<img src='http://img.php.cn/upload/article/000/005/656/5af270fd37755429.jpg' />");
  });
  $("button").click(function(){
    alert("函数已执行");
  });
});
</script>
</head>

<body>

<div id="txt"><h2>通过 AJAX 改变文本</h2></div>
<button>改变内容</button>
</body>
</html>
Run instance »

Click the "Run instance" button to view the online instance

Home

Videos

Q&A