Because we want to make a pad version of the web application, we need to avoid using frames to implement the page frame. According to the description of HTML5, it can be implemented with div css. But the problem is how to solve the partial refresh (refresh a certain frame)? If the div css is used and the content needs to be refreshed every time an event is triggered on the page, the entire page will be refreshed... This is definitely not possible! ! !
Please give me advice~~~~~~~~~
Use innerHTML to change the content as you like That's it.
<div id="d">abcd</div><script>function click_me(){ document.getElementById('d').innerHTML='new text';}</script><button onclick="click_me()">click</button>
Just use innerHTML to change the content.
HTML code
jquery's
$("#divID" ).load("xx.htm") page
Use jq's load method
http://api.jquery.com/load/
This is not a modification The problem with the two attributes is that the interface feels like switching the entire page of a certain section
Looking at the essence through the phenomenon, no matter what the jquery load method is,
in this case, innerHTML is used Do replacement of internal elements.
You can replace any number of elements with innerHTML.
jquery’s
$("#divID").load("xx.htm") page is enough
Let’s take a look at the master’s event
Uh, an old post from 2012~
Two processes:
1. Obtain document fragments or data from the server (the document fragments or data will have a data format, such as json, xml). You can use the XmlHTTPRequest object to get it in ajax mode, you can also get it in a concise way through frameworks such as jquery, or you can get it through webSocket.
2. Parse the document fragments fetched from the server into DOM fragments according to the agreed data format, and then append them to a node on the page. There will be JSON and XML objects in the browser environment, and their APIs have the parse() method, which can be parsed. However, there will be many redundant nodes, so regular expressions can be used to parse, which requires regular expressions. You need to write well, but I guess you are not proficient in asking this kind of question. Then you can find relevant js frameworks to complete the parsing process. I will not advertise these frameworks, not too many.
3. If this part of the DOM fragment needs to be bound to an event, it needs to be bound again. If step 2 is "replace" instead of append, the event is still there and there is no need to bind the event again.