// 定义要发送的数据 const currentUrl = window.location.href; const referrer = document.referrer; console.log(currentUrl,referrer); const data = { url: currentUrl, referrer: referrer, }; // 发起 POST 请求 $.ajax({ url: '/log/record.json', // 替换为实际的 API 地址 method: 'POST', contentType: 'application/json', data: JSON.stringify(data), success: function(response) { }, error: function(error) { } });