In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to add Ajax access pages to div". In daily operation, I believe many people have doubts about how to add Ajax access pages to div. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to add Ajax access pages to div". Next, please follow the editor to study!
Ajax gets the web page and adds it to div
1: use DOM to get the ID of the div, and then clear the contents of the DIV (do not empty if you need to add the next contents). It is important to note that it is best to use "empty ()"
2: set async to true, otherwise another warning error will prevent your content from being displayed. Here are the warning errors.
3: add HTML.
The specific code is as follows:
Test Baidu Test $(function () {$("# btn") .click (function () {$.ajax ({url:'../../Html/JQueryDome/ pop-up box .html', dataType:'html') Type:'get', async:true, success:function (data) {console.log (data) $("# tset") .html (data)}, error:function () {}})
Finally, summarize the methods of clearing the contents of DIv.
The content syntax in the empty () situation selector $("selector"). Empty () remove () delete and then restore the event is not in the syntax $("selector"). Remove () detach () delete and then restore the event in the syntax $("selector"). Detach ()
By the way, give me the rest:
Parcel
Wrap () each adds a new element syntax $("selector"). Wrap (") wrapAll () wraps an element syntax $(" selector "). Wrap (") wrapInner () adds a new element syntax $("selector"). Wrap (") unwrap () removes the parcel syntax $(" selector "). Wrap (" External insert after () insert syntax after: $("selector"). After (") insertAfter () insert syntax after: $(" selector "). InsertAfter (") before insert syntax after: $("selector"). Before (") insertBefore () insert syntax after: $ ("selector"). InsertBefore (") insert (in) append () insert syntax after: $(" selector "). Append (") appendTo () insert syntax after: $("). AppendTo (" selector ") prepend () insert syntax before: $(" selector ") .prepend (") PrependTo () inserts syntax before: $("). PrependTo (" selector ") replaces replaceWith () syntax $(" selector "). ReplaceWith ($(" selector ")) replaceAll syntax $(") .replaceAll ("selector" clone clone () syntax: 1. $(selector) .clone () .append (element name) 2, $(selector) .append ($(element name) .clone ())
By the way, there is another point (of course, I encountered in MVC, I am not sure there are all), that is, there is an internal JS in the acquired web page, for example, here is a time function to get the local time, and then when you execute AJAX, the page will not be added to the DIV, the whole page is the current time (but the address has not changed). Solution: you can delete the JS or replace the JS with an external JS.
At this point, the study on "how to add Ajax access pages to div" 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!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.