$(document).ready(function () {
// First AJAX call
$.ajax({
url: 'https://api.example.com/data1', // Replace with your API endpoint URL
method: 'GET',
dataType: 'json', // Set the expected data type
success: function (data) {
// Handle the data returned from the server
console.log('Data 1:', data);
},
error: function (xhr, status, error) {
// Handle errors if the AJAX call fails
console.error('Error in AJAX call 1:', error);
},
});
// Second AJAX call
$.ajax({
url: 'https://api.example.com/data2', // Replace with your API endpoint URL
method: 'POST',
data: {
param1: 'value1',
param2: 'value2',
},
dataType: 'json', // Set the expected data type
success: function (data) {
// Handle the data returned from the server
console.log('Data 2:', data);
},
error: function (xhr, status, error) {
// Handle errors if the AJAX call fails
console.error('Error in AJAX call 2:', error);
},
});
// You can add more AJAX calls as needed
});
1条答案
按热度按时间2sbarzqh1#
试试这个
字符串