Introduction
I will use the jQuery.ajax() or $.ajax() method to call the C# method (WebMethod). The $.ajax() method does an asynchronous HTTP (Ajax) request. This method will take various parameters. So you will get the entire parameters list in a link: https://api.jquery.com/jQuery.ajax/
You need to add the jQuery library to your project in order to run this jQuery Ajax call. You can download the jQuery library from this link: http://jquery.com/download/
Here is the jQuery Script.
Here is the C# function.
Output
Note
- Here I declared the C# method as WebMethod and it should be static.
- If this method is not static then you will get an error and the method will never be called.
- Download the code to test this $.ajax() functionality.