Asynchronous submission of JQuery and asynchronous submission of jquery

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.