Custom Object Class
First I’ll create a simple property class of City which has two simple properties
1. Name – Name of the City
2. Population – Population of the City.
This class will act as the JSON object for sending and receiving date between the client and server.
Above you will notice that on the click event of the HTML button btnCity I am making a jQuery AJAX call to the ASP.Net WebMethod GetCity which accepts a custom JSON object City with 2 properties (Name and Population). This function also returns a JSON object of type City with the same 2 properties (Name and Population).
Server side code
Below I have described the Web Methods that will process the requests received by the jQuery AJAX call.
The above Web Methods simply accept the object of class City and simply return it back to the client.
You can download the complete working source code in C# and VB.Net using the download link provided below.SendAndReceiveJSONObjectsjQueryASP.Net.zip