网站文章压缩储存OSS,请求地址使用鉴权地址,节省储存和带宽,文件也可以存放网盘,每100万个文章合并到1个文件即可。
代码例子
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pako/2.0.4/pako.min.js"></script>
<script>
$(document).ready(function () {
$.ajax({
url: 'https://59-47-225-42.pd1.cjjd19.com:30443/download-cdn.cjjd19.com/123-582/7c7a974f/1819092776-0/7c7a974f888e5709de800b9600f2e646/c-m67?v=5&t=1736562066&s=17365620665c838f06f98e16374ffef167248cdd95&r=0AMBDF&bzc=2&bzs=313831393039323737363a35323035323432313a35373930383434343935353a30&filename=1.mdb&x-mf-biz-cid=4ea854b3-4d0f-4449-a74a-4236ff5ee20f-47df1e&auto_redirect=0&cache_type=1&xmfcid=2952b5b4-12e1-4a91-9162-4cf9107650b1-0-50111d3b1',
method: 'GET',
headers: {
'Range': 'bytes=57908416664-57908444954' // 设置请求头,传递Range参数
},
xhrFields: {
responseType: 'arraybuffer' // 设置为 arraybuffer
},
success: function (data) {
// 将 ArrayBuffer 转为 Uint8Array
const compressedData = new Uint8Array(data);
// 解压数据
const decompressedData = pako.inflate(compressedData, {to: 'string'});
console.log("Decompressed Data:", decompressedData);
// 转换为 JSON 对象
try {
const jsonData = JSON.parse(decompressedData.trim());
$('#post-Content').html(jsonData['content']);
console.log("Parsed JSON Data:", jsonData);
} catch (error) {
console.error("JSON Parsing Error:", error);
}
},
error: function (xhr, status, error) {
console.error("Error:", error);
}
});
});
</script>由于工作需要长期使用Ajax,一个页面重复的AJAX请求太多,于是封装起来,只需要编写回调函数/* ------------- 使用方法: 1.ajaxrequest()函数执行准备的参数(1.请求地址2.发送数据字符串拼接3.type值可选get/post4.回调函数名称) exam...
<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> </head> ...
代码1:<!--代码开始--> <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script> <script>...
//构造函数 function Box(name,age){ this.name=name; this.age=age; this.run=function(){ return this.name+'--'+this.age; } } var&nbs...
//原型的缺点 function Box(){} Box.prototype={ 'name':'gao', age:23, family:['哥哥','姐姐','妹妹'], &...
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>点击复制</title> </head>...