博客
关于我
在 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 锁机制 mvcc_Mysql性能优化-事务、锁和MVCC
查看>>
MySQL 错误
查看>>
mysql 随机数 rand使用
查看>>
MySQL 面试题汇总
查看>>
MySQL 面试,必须掌握的 8 大核心点
查看>>
MySQL 高可用性之keepalived+mysql双主
查看>>
mysql 默认事务隔离级别下锁分析
查看>>
Mysql--逻辑架构
查看>>
MySql-2019-4-21-复习
查看>>
mysql-5.7.18安装
查看>>
MySQL-Buffer的应用
查看>>
mysql-cluster 安装篇(1)---简介
查看>>
mysql-connector-java各种版本下载地址
查看>>
mysql-EXPLAIN
查看>>
mysql-group_concat
查看>>
MySQL-redo日志
查看>>
MySQL-【1】配置
查看>>
MySQL-【4】基本操作
查看>>
Mysql-丢失更新
查看>>