What is asynchronous or Ajax. let's not talk about XMLHTTPRequest. in general, Asynchronization means that javascript on the front page can call the background method. in this way, there is no refresh. the so-called Ajax. here we will talk about two methods.
Method 1: (Microsoft has its own Ajax Framework)
In Asp.net, Microsoft has its own Ajax framework. This is to introduce the using System. Web. Services space in the page background. cs file and then define the static method (add [WebMethod] before the method).
[WebMethod]
Public static string ABC (string ABC)
{
Return ABC;
}
Now let's talk about how front-end Js processes the data returned by the backend. Jquery can be used to process the returned pure html, json, Xml, and other data. here we will demonstrate that the returned data includes string, set (List <>), and class.
But they all return the Json format (Json is lightweight and easier to process than XML). Let's see how the front-end parses the data.
The Code is as follows:
Front-end page:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Default2.aspx. cs" Inherits = "Default2" %> No title page