Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AJAX启动和AJAX停止不工作_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript AJAX启动和AJAX停止不工作

Javascript AJAX启动和AJAX停止不工作,javascript,jquery,ajax,Javascript,Jquery,Ajax,开始时,我在我的页面中尝试了ajaxStart和ajaxStop,但都不起作用,代码: <!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script language="javascript" src="jquery

开始时,我在我的页面中尝试了
ajaxStart
ajaxStop
,但都不起作用,代码:

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script language="javascript" src="jquery-1.11.1.js"></script>
</head>
<body>
<form name="form" method="post" action="">
    <input id = "name" type="text" name = "name" value="">
    <div id = "check"></div>
</form>

<script language="javascript">
       $("#name").blur(function() {
           $("#name").ajaxStart(function() {
               $("#check").html("loading...");
               alert("loading...");
           });
           $("#name").ajaxStop(function() {
               $("#check").html("OK...");
               alert("OK...");
           });
           $.ajaxSetup({
               url : "check.php",
               type : "POST",
               success : function(data) {
                   $("#check").html(data);
               },
           });
           $.ajax({
               url : "checkname.php",
               type : "POST",
               data : {name : $("#name").val()},
               datatype : "text",
               beforeSend : function() {
                   console.log("beforeSend");
               },
               success : function(data) {
                   $("#check").html(data);
                   console.log("success");
               },
               error : function() {
                   $("#check").html("error");
                   console.log("error");
               },
               complete : function() {
                   console.log("complete");
               },
           });
       });
</script>
</body>
</html>
另外,我尝试了另一种方法,使用jQuery 1.7.2,它可以在
$(“#name”).ajaxStart()上运行

我的问题是:

1、 为什么在jQuery 1.11.1中,
$(“#name”).ajaxStart()
不起作用,与1.7.2相比有什么变化

2、 是否有一些网站给我的jQuery的每个版本的差异,细节会更好

感谢您的帮助。

1)如jQuery官方文档所述, 从jQuery 1.8开始,.ajaxStart()方法只能附加到文档。

2) 对于第二次查询,jQuery官方文档应该足够了 对于不推荐的东西

$(document).ajaxStart(function() {
    $("#check").html("loading...");
    alert("loading...");   
});