博客
关于我
在 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 DBA 数据库优化策略
查看>>
multi_index_container
查看>>
MySQL DBA 进阶知识详解
查看>>
Mura CMS processAsyncObject SQL注入漏洞复现(CVE-2024-32640)
查看>>
Mysql DBA 高级运维学习之路-DQL语句之select知识讲解
查看>>
mysql deadlock found when trying to get lock暴力解决
查看>>
MuseTalk如何生成高质量视频(使用技巧)
查看>>
mutiplemap 总结
查看>>
MySQL DELETE 表别名问题
查看>>
MySQL Error Handling in Stored Procedures---转载
查看>>
MVC 区域功能
查看>>
MySQL FEDERATED 提示
查看>>
mysql generic安装_MySQL 5.6 Generic Binary安装与配置_MySQL
查看>>
Mysql group by
查看>>
MySQL I 有福啦,窗口函数大大提高了取数的效率!
查看>>
mysql id自动增长 初始值 Mysql重置auto_increment初始值
查看>>
MySQL in 太多过慢的 3 种解决方案
查看>>
MySQL InnoDB 三大文件日志,看完秒懂
查看>>
Mysql InnoDB 数据更新导致锁表
查看>>
Mysql Innodb 锁机制
查看>>