博客
关于我
在 selenium IDE 插件中添加上传云端平台的功能
阅读量:279 次
发布时间:2019-03-01

本文共 2080 字,大约阅读时间需要 6 分钟。

          /**            * 原生 JavaScript 的 Ajax 函数           * @type { {get: Ajax.get, post: Ajax.post}}           */          const Ajax = {            get: function(url, fn) {              // 使用 XMLHttpRequest 对象进行数据交互              var xhr = new XMLHttpRequest();              xhr.open('GET', url, true);              xhr.onreadystatechange = function() {                // 当请求完成时处理回应                if ((xhr.readyState == 4 && xhr.status == 200) || xhr.status == 304) {                  fn.call(this, xhr.responseText);                }              };              xhr.send();            },            post: function(url, data, fn) {              // 使用 XMLHttpRequest 发送 POST 请求              var xhr = new XMLHttpRequest();              xhr.open('POST', url, true);              xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');              xhr.onreadystatechange = function() {                // 处理服务器返回的响应                if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 304)) {                  fn.call(this, xhr.responseText);                }              };              xhr.send(data);            }          };                    export function uploadProject(_project) {            // 将项目对象转换为 JSON 格式            const project = _project.toJS();            const sideJson = JSON.stringify(project);                        ModalState.showAlert({              title: '上传云端',              description: sideJson,              confirmLabel: '确定',              cancelLabel: '取消'            }, choseUpload => {              if (choseUpload) {                // 服务器地址配置(示例)                const host = 'https://localhost:9000';                const token = uuidv4();                const data = {                  name: project.name,                  sideJson: sideJson,                  token: token                };                                // 发送 POST 请求                Ajax.post(`${host}/uitestcase/upload.api`, JSON.stringify(data), res => {                  console.log(res);                });              }            });          }        

转载地址:http://nsea.baihongyu.com/

你可能感兴趣的文章
Mysql 重置自增列的开始序号
查看>>
MySQL 高可用性之keepalived+mysql双主
查看>>
mysql-connector-java各种版本下载地址
查看>>
mysql-group_concat
查看>>
MySQL-【4】基本操作
查看>>
Mysql-丢失更新
查看>>
Mysql-事务阻塞
查看>>
Mysql-存储引擎
查看>>
mysql-开启慢查询&所有操作记录日志
查看>>
MySQL-数据目录
查看>>
MySQL-数据页的结构
查看>>
MySQL-架构篇
查看>>
MySQL-索引的分类(聚簇索引、二级索引、联合索引)
查看>>
Mysql-触发器及创建触发器失败原因
查看>>
MySQL-连接
查看>>
mysql-递归查询(二)
查看>>
MySQL5.1安装
查看>>
mysql5.5和5.6版本间的坑
查看>>
mysql5.5最简安装教程
查看>>
mysql5.6 TIME,DATETIME,TIMESTAMP
查看>>