current position:Home>Simple and easy to let you know what AJAX is, even if you are a little white, a rookie can understand it!

Simple and easy to let you know what AJAX is, even if you are a little white, a rookie can understand it!

2022-04-29 09:06:21Sun Xiao~

What is? ajax Well ? Look here ! Combined with real examples , Easy to understand , If you look at it, you will !

Digression : For personal reasons , When the teacher says ajax When , I'm not at school , So I didn't hear about ajax The content of , Led to seeing... For some time ajax It's a headache ! Later, I came into contact with more , I've come to understand . Now I'll tell those who don't understand , incomprehension ajax Classmate . I hope we can make progress together . If the boss sees this article , If there is something wrong, please point it out , I'll do the trimming ! After all, I am also a newcomer who has just worked , The understanding of these technologies may not be comprehensive and in-depth ! Thank you for the !
Let's take a look at the more official statement :
AJAX Is a technology for creating fast dynamic web pages .

AJAX Through a small amount of data exchange with the server in the background , Make web pages update asynchronously . This means that you can , Update some parts of the web page .

Traditional web pages ( Don't use AJAX) If you need to update the content , You must reload the entire page .

See here , Xinmeng will be confused , I don't know ! Let me use a simple and easy to understand example , Show you what is ajax!

Popular understanding ajax!

Now imagine a scenario , Now I have a boss , The boss is in a meeting , Then a client calls the boss , To purchase a batch of goods from the boss , What will the boss do at this time , The boss will ask the secretary next to him to do it , Let's call this secretary “ajax” Well ,ajax What kind of process is it to do this , He should go to the warehouse first , Then check the quantity of the goods , Whether to meet the quantity purchased by customers . Then he told the boss whether the quantity of goods was enough or not , Finally, the boss will tell him , What should I do if I have enough , What should I do if it's not enough !

The simple scene above , I'm sure you can understand . So let's go back to ajax!, Say ajax Before , Let's talk about ajax The advantages of .
1、 The biggest point is that the page does not refresh , Communicate with the server within the page , The user experience is very good .
2、 Communicate with the server asynchronously , No need to interrupt the user's operation , More responsive .
3、 We can transfer the burden of the previous server to the client , Take advantage of the client's idle ability to handle , Reduce the burden of servers and bandwidth , Save space and broadband rental costs . And reduce the burden on the server ,ajax The principle of “ On demand data ”, Minimize redundancy requests , And the burden of response on the server .
4、 Based on standardized and widely supported technologies , No need to download plug-ins or applets .

what ? You can't understand the advantages you say ?? No problem , See the following step-by-step analysis for you !

ajax Use

The way JQuery in ajax Use , This is also the one we use most !
complete $.ajax Parameters More complicated , The common calling method is adopted here .

1)$.ajax({
    
   url:  Represents the path to access ,
   data: Indicates the submitted parameter ,
   success: function(result){
    
      // Write here what you want to do 
   }
});

// Let's talk about the above scene , How does it work ajax Of .2)$.ajax({
    
   url: // Represents the path to access , This can be understood as  “ Go to the warehouse ”, Is to guide ajax How can we go there? 
   data:// Indicates the submitted parameter , Can be interpreted as   What do you need to take to the warehouse , In this scene ,ajax We need to know which goods the customer purchases , So he needs to bring the name of the goods 
   success: function(result){
    //success Can be interpreted as ,ajax After counting the quantity of goods in the warehouse , What to do next .result It can be understood as the result , In fact, counting goods is a process of inquiry ,
      if(result>100){
    // For example, the customer wants to 100 individual , The query result is greater than 100, Then you can deliver goods to customers 
     //  Quantity of goods to meet customer requirements , Can deliver goods to customers 
		}else{
    // If the goods are less than what the customer wants 100 individual , Then you can't deliver .
		// Quantity of goods that do not meet customer requirements .
		}
   }
});

You should understand by now , Let's combine this scene , Come on ajax The advantages of
1、 The biggest point is that the page does not refresh , Communicate with the server within the page , The user experience is very good : The boss just needs to let ajax Just do it , What the boss should do !
2、 Communicate with the server asynchronously , No need to interrupt the user's operation , More responsive : Because it makes ajax Did it , Do not affect others , So what should others do , Again because ajax There is a purpose , Targeted , So he will do it very quickly !
3、 We can transfer the burden of the previous server to the client , Take advantage of the client's idle ability to handle , Reduce the burden of servers and bandwidth , Save space and broadband rental costs . And reduce the burden on the server ,ajax The principle of “ On demand data ”, Minimize redundancy requests , And the burden of response on the server : without ajax This secretary , Then the boss needs to do it himself . If everything needs to be done by the teacher himself , The boss is too tired . Tired to a certain extent , The boss is dead tired , The server crashed ! There is now a ajax This secretary , The boss is not so tired !
4、 Based on standardized and widely supported technologies , No need to download plug-ins or applets : In the scene ajax It's a person , With arms and legs , Just get started on what you want to do , You can put his arm in again , Leg mounting , Put your head on .

ending :

Come here ,ajax That's about it , My blog is not about how to use ajax, I want to tell you , How to better understand ajax.ajax There are more parameters , We need to learn more ! Here is an example of my own study java Website , I think it's good . It is very suitable for newcomers to learn by themselves java. Now send this website to explain ajax, I hope that's helpful !
https://how2j.cn/k/jquery/jquery-ajax/474.html?p=115656

I created an exchange myself java Group , Because I'm also a newcomer , There are many places to improve and learn , I hope you will join us !
Group :917421921

They are both rookies , Let's make progress together ! come on. !

copyright notice
author[Sun Xiao~],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204290627138810.html

Random recommended