javascript - 在ajax(请求)中循环仅第一个结果有效
问题描述
我不明白为什么 ajax 循环只在第一个结果上以及如何修复它?
arrayOfMatches.forEach((matchesOfElement) => {
var query = {
platformId: matchesOfElement.platformId,
gameId: matchesOfElement.gameId,
champion: matchesOfElement.champion,
queue: matchesOfElement.queue,
season: matchesOfElement.season,
timestamp: matchesOfElement.season,
role: matchesOfElement.role,
lane: matchesOfElement.lane,
summonerName: summoner.name,
summonerAccountId: summoner.accountId,
}
$.ajax({
url: 'matches.php',
method: 'POST',
data: query,
success: function(data) {
console.log(data);
},
error: function(response, xhr, statusText) {
console.log(response);
},
});
});
}
唯一的唯一值是“gameId”
提前致谢!
解决方案
推荐阅读
- python - 如何修复没有名为“tensorflow.python.ops.numpy_ops”的模块
- carousel - 我可以使用 swiper 在一个页面上有两个垂直、相对的滑块吗?
- c# - 在 WebBrowser 控件的 HTML 中嵌入资源图像
- python - sqlalchemy 只插入没有匹配列值的记录
- if-statement - 如何满足我的(多个)条件?
- python - 使用 beautifulsoup 抓取网页时获取颜色代码
- python - 解释为什么在 gen_py 中删除文件夹可以解决 wincom32 错误 no attribute 'CLSIDToPackageMap'
- javascript - 为什么 QuerySelectorAll 在我的模式页面上不起作用
- python - Django 休息框架 | TypeError:字段 'id' 需要一个数字,但得到了 OrderedDict([('name', 'string')])
- python - 创建直方图,忽略某些特定值