片段js: delHistory.click(function() { searchHistory = []; // 清空搜索历史 $.ajax({ url: 'http://www.tt.com/index.php?v=1&appid=1&appsecret=PHPCMFDD5692D5D6FE9&', method: 'post', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, data: $.param({ ip: ip }), // 序列化对象为URL编码的字符串 success: function(response) { console.log("成功发送IP地址,后端响应为:", response); }, error: function(xhr, status, error) { console.error("发送IP地址时出错:", error); } }); initSuggestions(); // 重新初始化建议列表 }); php自定义函数文件 function handleReceivedIP($ip) { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $ip = \Phpcmf\Service::L('input')->post('ip'); // 查询dr_search_log表,找到与给定IP匹配的记录 $result = \Phpcmf\Service::M()->db->table('dr_search_log')->where('ip', $ip)->get(); // 如果找到匹配的记录,执行删除操作 if ($result) { \Phpcmf\Service::M()->db->table('dr_search_log')->where('ip', $ip)->delete(); } else { return; } } }