How To Use Ajax In Jquery?

jQuery provides several methods for AJAX functionality . The $.ajax( ) function is used to perform an asynchronous HTTP request . It is often unnecessary to directly call this function, as several higher-level alternatives like $.get() and .load() are available and are easier to use.

$.ajax(url)

The URL of the server-side resource to which the request is sent. It could be a CGI, ASP, JSP, or PHP script which generates data dynamically or out of a database. With the jQuery AJAX methods, you can request text, HTML, XML, or JSON from a remote server using both HTTP Get and HTTP Post . Loading Data example
<!DOCTYPE html> <html lang="en"> <head> <title>jQuery Ajax() method</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type = "text/javascript" language = "javascript"> $(document).ready(function() { $('.loader').click(function(){ $.ajax('your-URL',{ success: function (data, status, xhr) { $('p').append(data); } }); }); }); </script> </head> <body> <input type = "button" class = "loader" value = "Load Data" /> <p></p> </body> </html>