什么是jQuery中的jQuery.ajaxSetup()方法?

jQuery.ajaxSetup()方法为将来的AJAX请求设置全局设置。这是此方法使用的所有参数的说明-

假设我们在result.html文件中包含以下HTML内容,

<h1>这是结果... </ h1>

以下是显示此方法用法的示例。在这里,我们使用成功处理程序来填充返回的HTML:

<html>

   <head>
      <title>The jQuery Example</title>
      <script src = "https://cdn.staticfile.org/jquery/2.1.3/jquery.min.js"></script>
       
      <script>
         $(document).ready(function() {
           
            $("#driver").click(function(event){
               //进行全局设置。
               $.ajaxSetup({
                  url: "result.html"
               });
                   
               $.ajax( {
                  success:function(data) {
                     $('#stage').html(data);
                  }
               });
            });
         });
      </script>
   </head>
   
   <body>
   
      <p>Click on the button to load result.html file:</p>
       
      <div id = "stage" style = "background-color:#cc0;">
         STAGE
      </div>
       
      <input type = "button" id = "driver" value = "Load Data" />
       
   </body>
</html>