There is a requirement in the project to load the data using AJAX to return the page and assign the value, and then the front end to remove the value
This involves the sequence of code issues, sometimes the background has not returned data, but has executed the following code,
So it's going to take the value out.
$.ajax ({type: "post", URL: "Admin/pfmoptionruleitem.do", success:function (data) { $ ("#ruleItem"). Val ( Data.ruleitem); ①}}); Return $ ("#ruleItem"). Val (); Ii
If ① has not returned data from the background, then the execution ② is not getting the value
The first letter of Ajax is the asynchronous letter, which means that all operations are parallel and the order of completion is not related.
The async parameter of $.ajax () is always set to true, which indicates that other code can still be executed after the request has started.
If you set this option to false, this means that all requests are no longer asynchronous, which can also cause the browser to be locked.
Although the official does not recommend this, but can not use too much, otherwise it will result in poor user experience
Give me a chestnut.
Alert ("Setp 1"); $.ajax ({ URL: "admin/pfmoptionruleitem.do", Async:false, success:function (data) { alert ("Hello Ajax "); ① }}); Alert ("Setp 2"); Ii
When the Asyn is set to False, the AJAX request is synchronized, that is, when the Ajax block makes a request,
He would wait in ① this place, would not go down to execute ② until ① finished
This is done sequentially
SETP 1
Hello Ajax
SETP 2
If Async is true, the execution order is
SETP 1
SETP 2
Hello Ajax
About this article to everyone described in the jquery Ajax async Synchronous and asynchronous, all introduced, I hope to help.