如何使用控制台日志调用多个 ajax 请求

How to call multiple ajax request using console log

如何使用控制台日志多次调用 ajax 请求。

我已回复 XHR 以正常工作,但我需要使用控制台日志发送多个请求。有什么想法吗?

如果循环看起来像这样:

for(var i=0; i<10; i++){
   $.ajax({
    //
    success:function(data){
       $("#p" + i + "_points").html(data);
    }
   });
}
it will not work as i will end up being the last i value in the loop; You need something like below

for(var i=0; i<10; i++){
   (function(index){
      $.ajax({
       //
       success:function(data){
          $("#p" + index + "_points").html(data);
       }
      });
   })(i);
}
The closure along with the passing of i will keep number value for that call.

of course there will need to exist elements with ids 1-10 or whatever number you use so:

<element id="p1_points">
<element id="p2_points">
<element id="p3_points">
...