Asynchronous submission of JQuery and asynchronous submission of jquery
When it comes to asynchronous submission, you must first think of ajax, because it serves asynchronous operations. But here I want to talk about JQuery. What is the relationship between the two? I think JQuery is actually an encapsulation of JS. Just like when we operate JavaScript, we basically perform direct operations on DOM nodes. For example, to obtain the value of a node, we need to use the document. getElementByID method and then assign values to it. It's a huge job to write a lot of code, like ajax asynchronous operations. But with JQuery, you only need to call a method. Simply put, it is an encapsulation of JS, which uses the least code to improve our efficiency. It is like Encapsulating some common methods in the system.
JQuery asynchronous operations actually have many methods, such as the $. get method, the $. post method, and the $. ajax method. First, take the post method as an example and look at the following code:
$. Post ("/Test/jsonTest", {ids: txtName}, function (data ){
$. Messager. alert ("prompt message", data );});The preceding parameter indicates that the first parameter is URL (the server address of the request) and the second parameter (the data to be transmitted ), the third is the callback function (the operation after successful request ). Compared with the original ajax submission, JQuery's post method is much more convenient. Next let's look at the ajax method:
$. Ajax ({
Url: '/Test/About? TxtName = '+ $ ("# searchName "). val (), type: 'get', contentType: 'application/string; charset = UTF-8 ', success: function (data) {alert (data );}})
The same effect as the post method above is achieved. The most concise code is used to achieve the desired effect, which greatly improves our development efficiency.Conclusion: In the past, I felt like JQuery was mysterious, or it was very likely to trigger this. Now I have read this article. In fact, it can be understood as the method encapsulation in the object-oriented method.