配置请求:方法(GET/POST)、URL、是否异步xhr.open('GET', 'https://api.example.com/data', true);// 3....== 200) { // 请求成功console.log('返回数据:', xhr.responseText);} else {console.error('请求失败,状态码:', xhr.status...3️⃣ 使用 jQuery 简化 AJAX$.ajax({url: 'https://api.example.com/data', // 请求地址type: 'GET', ...('返回数据:', response);},error: function(xhr, status, error) { // 请求失败回调console.error('请求失败:', status, error...5️⃣ 小技巧GET vs POSTGET:适合获取数据,数据量小,参数显示在 URL。POST:适合提交数据,数据量大,更安全。