Get the App
SLTechnology News&Howtos  ›  Development  › 

Ajax in jquery returns a result instead of a callback, which means that the method tutorial is executed in the same order.

Shulou Source: shulou.com Published: 2022-06-03 08:13:15 10月03日 Update

This article mainly introduces "the method tutorial in the same order when ajax returns results in jquery instead of callbacks". In daily operations, it is believed that many people have doubts about the problem that ajax returns results rather than callbacks in jquery. The editor consulted all kinds of materials and sorted out simple and useful operation methods. I hope it will be helpful for you to answer the doubt that "the ajax in jquery returns results rather than callbacks, that is, the method tutorial is executed in the same order"! Next, please follow the editor to study!

Because the default ajax is asynchronous, that is, it does not affect downward execution when the result is not responded to. Therefore, it must be realized by callback. This scheme is more efficient.

If you do not want to return a result, change the parameter async in ajax to false, which will be executed in the same order. You can return the result by implementing the following.

However, this practice is not recommended when it is not necessary.

The copy code is as follows:

Function (url,params) {

Var outdata

$.ajax ({

Type: "get"

Async:false

DataType: "json"

Url: url

Data: params

Success: function (data) {

Outdata = data

}

Error:function (e) {

Alert ('ajax error')

}

});

Return outdata

}

At this point, the study on "the method tutorial that the ajax in jquery returns results rather than callbacks is executed in the same order" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Results methods methods order tutorials learning code more help practical necessary and then that is practices parameters situations efficiency articles schemes theories Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Technology Apple OPPO Reno MariaDB