Sending multiple data parameters with jQuery AJAX

To send multiple data parameters with jQuery's $.ajax() function in PHP, you can use the data option and set it to an object with the data you want to send. Here's an example:

$.ajax({
  url: 'example.php',
  type: 'POST',
  data: {
    name: 'John',
    age: 30,
    city: 'New York'
  },
  success: function(response) {
    // handle response
  }
});

Watch a course Learn object oriented PHP

This will send a POST request to example.php with the data parameters name, age, and city set to 'John', 30, and 'New York' respectively.

On the PHP side, you can access the data using the $_POST superglobal array:

$name = $_POST['name'];
$age = $_POST['age'];
$city = $_POST['city'];

You can also send data in the query string of the URL by setting the data option to a string in the following format: key1=value1&key2=value2&key3=value3

For example:

$.ajax({
  url: 'example.php?name=John&age=30&city=New York',
  type: 'GET',
  success: function(response) {
    // handle response
  }
});

This will send a GET request to example.php with the data parameters name, age, and city