This article mainly introduces the JQuery-based $. ajax method for asynchronous requests that cause page flashes. it is of great reference value. For more information, see
Scenario
Currently, you need to fill in the content in the text box to automatically trigger the keyup event. the drop-down list will automatically filter the corresponding options, but $ is used. after ajax is found, each time an event is triggered, causes the entire webpage to flash, triggering a global ajax event.
Code snippet
$. Ajax ({type: "POST", url: root + "/xxx, data: requestData, dataType:" json ", success: function (data) {// clear the list $ ("# formOpinion # listLeft "). empty (); $. each (data, function (I, $ data) {var $ option = $ (""+ $ Data. code + $ data. name +""); // Bind data to listLeft $ (" # formOpinion # listLeft "). append ($ option );});}});
Solution
Check the JQuery API documentation and find that $. ajax has a Global attribute that can be used to set whether a Global range of ajax events. the default value is true, and the value can be changed to false.
The above content is a small part of the JQuery-based $. ajax method for asynchronous requests that cause page flashes. I hope to help you all!