weixin_33697898 2017-04-18 07:35 采纳率: 0%
浏览 4

循环内的Ajax调用

I have a loop in my jQuery code. Inside the loop there is an AJAX call. Since for each loop an AJAX call to the server is fired, does it mean a new thread is created for each call at the server side? Do all calls get a new thread? This is my jQuery code for your reference:

function Run() {
  var i = 0;
  var r = '${result}'
  var par = '${paramy}'
  var str = r.replace(/?
|/g, " ");
  var resjson = JSON.parse(str);
  var parjson = JSON.parse(par);

  //loop to send ajax req multiple times. 
  for (var i = 0; i < resjson.length; i++) {
    var k = i + 1;
    var m = encodeURIComponent(JSON.stringify(resjson[i]));
    var py = encodeURIComponent(JSON.stringify(parjson));
    var pass = '';

    $.ajax({
      type: 'post', // it's easier to read GET request parameters
      url: 'servlet1',
      async: true,
      data: { 
        r: m,
        p:py
      },
      success: function(data) {
        console.log("pass"`enter code here`)
      },
      error: function(data) {
        console.log("fail"); 
      }
    });
  }
}
  • 写回答

2条回答 默认 最新

  • weixin_33697898 2017-04-18 07:53
    关注

    Since for each loop an AJAX call to the server is fired, does it mean a new thread is created for each call at the server side?

    That depends entirely on the infrastructure being used on the server side. Few servers would create a brand-new thread for each request but many would assign a thread from a pool to each request, and return that thread to the pool when the request is serviced.

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测