jquery - 数组中每个项目的 jQuery API 调用(插入查询)
问题描述
这是我第一次使用 API,我在本地机器上创建了一个非常简单的 REST API,并带有一个非常简单的 jquery 前端。我试图找出使用我的 ajax post 调用我的 API 在我的数据库中创建一个新项目的最佳方式。
// sample code:
$.ajax({
url: "http://localhost/first_attempt/api/product/create.php",
type: "POST",
contentType: 'application/json',
data: {
"client_name": "foo",
"date": "2020-01-01",
"value": "2",
"item": "report_viewer"
},
success: function(result) {
bootbox.alert("Value has been added successfully.", showValues());
},
error: function(xhr, resp, text) {
console.log(xhr, resp, text);
}
});
我希望能够在for
循环中使用它,但我不确定如何在每次调用从 API 获取响应时如何做到这一点,并且不使用请求重载 API,然后它不会完成。
您可以分享的任何建议将不胜感激。
解决方案
推荐阅读
- r - 如何从固定值开始进行“滚动”乘法
- reactjs - 如何在 SLDSGlobalHeader 组件的徽标中创建链接?
- regex - 正则表达式匹配前 3 个数字
- solidity - 如何在 Solidity 中正确测试异常?
- powershell - Powershell cmd 获取与特定字符不匹配的包含
- r - 如何在 ubuntu 中安装特定的 R 版本
- python - 降低小数的 NumPy 数组的分辨率
- flutter - Flutter 错误:配置项目“:电话”时出现问题
- pandas - 如何在熊猫中标记特定时间的日期时间索引?
- javascript - 在画布上绘图时的 javascript promis / async / await 行为