javascript - 通过 XMLHttpRequest (API) 在 HTML 表上显示请求结果
问题描述
我的代码设法使用 API 请求提取结果,但我似乎无法找到将请求正文显示到我的 HTML 中的方法。
Var request = new XMLHttpRequest();
request.open('POST', 'https://api.tookanapp.com/v2/get_all_tasks');
request.setRequestHeader('Content-Type', 'application/json');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
}
var body = {
"api_key": "51676580f24b091114132d38111925401ee4c2f328d978375e1f03",
"job_status": 6,
"job_type": 1,
"start_date": "2020-08-20",
"end_date": "2021-12-25",
"custom_fields": 1,
"is_pagination":1,
"requested_page":1,
"customer_id":"",
"job_id": [],
"order_id": [],
"team_id":921691
}
request.send(JSON.stringify(body));
解决方案
推荐阅读
- arrays - 创建一个函数,该函数接受两个或多个数组并返回它们的对称差值数组。返回的数组必须只包含唯一值
- vue.js - 产品卡悬停上的 Init Vue Awesome swiper
- java - 如何使用 Java 客户端通过 SSL 连接到 MQTT 代理?
- android - 使用 NavigationComponent 和单个 Activity 时,如何防止我的设备读取每个 Fragment 中的 NFC 标签?
- django-models - django user.save() 在 create_user 函数中不起作用
- flutter - 无效的 depfile ...kernel_snapshot.d
- javascript - 响应式导航栏
- javascript - 如何从反应日期范围选择器中删除输入范围?
- python - 在 Airflow 中创建与 AWS ec2 实例的 SSH 连接
- javascript - Image Cache issue using Laravel