Javascript 从ajax调用到php的2个响应

Javascript 从ajax调用到php的2个响应,javascript,jquery,ajax,Javascript,Jquery,Ajax,在下面的代码中,我需要响应中的2个值 被调用页面url的Html响应 用于获取页面或调用中使用的数组索引的URL值 for (i = 0; i < pageURLs.length; i++) { $.ajax({ url: pageURLs[i], dataType: 'html', statusCode: { 200: function(response) { /*i am only getting acce

在下面的代码中,我需要响应中的2个值

  • 被调用页面url的Html响应

  • 用于获取页面或调用中使用的数组索引的URL值

      for (i = 0; i < pageURLs.length; i++) {  
        $.ajax({
    
        url:  pageURLs[i],
        dataType: 'html',
        statusCode: {
            200: function(response) {
              /*i am only getting access to the html of the page HERE*/
    
    
    
            },
            404: function() {
                  /*404 here*/
    
            }
        },
        error: function(error) {
    
        }
    });}
    
    (i=0;i $.ajax({ url:pageURLs[i], 数据类型:“html”, 状态代码:{ 200:功能(响应){ /*我在这里只能访问页面的html*/ }, 404:函数(){ /*这里是404*/ } }, 错误:函数(错误){ } });}

  • 编辑这里有一种更轻量级的方法,使用
    let
    。有关解释,请参阅原始答复

    注意此语法可能与旧浏览器不兼容…:(


    }编辑这里有一种更轻量级的方法,使用
    let
    。有关解释,请参阅原始响应

    注意此语法可能与旧浏览器不兼容…:(


    }编辑这里有一种更轻量级的方法,使用
    let
    。有关解释,请参阅原始响应

    注意此语法可能与旧浏览器不兼容…:(


    }编辑这里有一种更轻量级的方法,使用
    let
    。有关解释,请参阅原始响应

    注意此语法可能与旧浏览器不兼容…:(

    }

    for (i = 0; i < pageURLs.length; i++) {
        let j = i;  
        $.ajax({
            url:  pageURLs[j],
            dataType: 'html',
            statusCode: {
                200: function(response) {
                   /* now you can also access j */
                   console.log("j=", j);
                },
                404: function() {
                  /*404 here*/
                }
            },
            error: function(error) {
                // error processing
            }
        });
    }
    
    for (i = 0; i < pageURLs.length; i++) {  
        (function(i) {
            $.ajax({
            url:  pageURLs[i],
            dataType: 'html',
            statusCode: {
                200: function(response) {
                 /*i am only getting access to the html of the page HERE*/ 
                 /* now you can also access i */
                },
                404: function() {
                  /*404 here*/
    
                }
            },
            error: function(error) {
    
            }});
        }(i);