博客
关于我
在 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缓存调优的基本知识(附Demo)
查看>>
mysql编写存储过程
查看>>
mysql网站打开慢问题排查&数据库优化
查看>>
mysql网络部分代码
查看>>
mysql联合索引 where_mysql联合索引与Where子句优化浅析
查看>>
mysql联合索引的最左前缀匹配原则
查看>>
MySQL聚簇索引
查看>>
mysql自动化同步校验_Shell: 分享MySQL数据同步+主从复制自动化脚本_20190313_七侠镇莫尛貝...
查看>>
Mysql自增id理解
查看>>
mysql自增id超大问题查询
查看>>
MySQL自定义变量?学不废不收费
查看>>
MySQL自带information_schema数据库使用
查看>>
MySQL获取分组后的TOP 1和TOP N记录
查看>>
mysql虚拟列表_动态网页制作-官方版合集下载-多特
查看>>
MySQL蜜罐反制获取攻击者信息
查看>>
Mysql表创建外键报错
查看>>
mysql表格调取数据库信息_MySQL™ 参考手册(获取有关数据库和表的信息)
查看>>
mysql表检查分析优化
查看>>
WARN: Establishing SSL connection without server‘s identity verification is not recommended.
查看>>
MySQL要点总结二
查看>>