// Make an AJAX request to a PHP script that returns a JSON response $.ajax({ url: "script.php", type: "POST", dataType: "json", data: { name: "John", age: 30 }, success: function(response) { console.log(response); }, error: function(jqXHR, textStatus, errorThrown) { console.log(textStatus, errorThrown); } });
// Send form data to a PHP script using AJAX $("#submit-form").click(function(e) { e.preventDefault(); var data = $("#my-form").serialize(); $.ajax({ url: "script.php", type: "POST", data: data, success: function(response) { console.log(response); }, error: function(jqXHR, textStatus, errorThrown) { console.log(textStatus, errorThrown); } }); });From these examples, it's clear that PHP Request Ajax utilizes the jQuery library for making the AJAX requests. It provides a convenient way to send and receive data from a PHP script without requiring a page reload.