<script> $(document).ready(function() { $.ajax({ url: 'your_url_here', type: 'POST', // 或者 'GET' contentType: 'application/json', dataType: 'json', data: JSON.stringify({ key1: value1, key2: value2 }), // 将数据转换为 JSON 字符串 success: function(response) { // 请求成功时的处理逻辑 console.log('请求成功', response); }, error: function(xhr, status, error) { // 请求失败时的处理逻辑 console.error('请求失败', status, error); } }); }); </script>