$getJSON and for loop issue

后端 未结 4 1858
野性不改
野性不改 2020-12-01 10:01

This is to populate a table with the amount of results that are returned from the MediaWiki API query /api.php?action=query&list=querypage&qppage=BrokenRedirec

4条回答
  •  眼角桃花
    2020-12-01 10:32

    You should write a function like -

    function callUrl(value)
    {
     $.getJSON('/api.php?action=query&list=querypage&qppage=' + value + '&format=json', function (data) {
            $('#' + value).text(data.query.querypage.results.length);
        });
    }
    

    and then call it with some timeout option like -

    setTimeout('callUrl(+ array[i] +)',500); within the loop -

    i.e.

    for (var i = 0; i < array.length; i++) {
      setTimeout('callUrl(+ array[i] +)',500);
    }
    

    Some delay for each call will be required here.

提交回复
热议问题