How can I limit the number of requests per second? There is a certain script and it is necessary that the number of requests does not exceed N, otherwise the server generates an error.
var q = items.reduce(function (prev, item) { return prev.then(function () { return $.ajax({ dataType: 'json', url: 'https://example.com/method/methodOne?callback=?' }).then(function (results_one) { console.log(results_one); return $.ajax({ dataType: 'json', url: 'https://example.com/method/methodTwo?callback=?' }).then(function (results_two) { console.log(results_two); }); }); }); }, $.when([]));