Enabling updates for specific html elements only

I would like to know how can I only update a specific item on my website, and not the entire web page? The item I'm talking about is a flash application that loads rather slowly and can experience connection timeouts. I want to allow the user to update only this element / falsh application. How can I do it? Below I have an Ajax function that updates an HTML element but does not know how to apply it to my situation.

<head> <script type="text/javascript"> function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("myDiv").innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET", "ajax_info.txt", true); xmlhttp.send(); } </script> </head> <body> <div id="myDiv"> <h2>Let AJAX change this text</h2> </div> <button type="button" onclick="loadXMLDoc()">Change Content</button> </body> 
+7
source share
4 answers

Try the following:

 function reload(){ var container = document.getElementById("yourDiv"); var content = container.innerHTML; container.innerHTML= content; //this line is to watch the result in console , you can remove it later console.log("Refreshed"); } 
 <a href="javascript: reload()">Click to Reload</a> <div id="yourDiv">The content that you want to refresh/reload</div> 

Hope this works. Let me know

+16
source

Try creating a javascript function that runs this:

 document.getElementById("youriframeid").contentWindow.location.reload(true); 

Or perhaps use the HTML workaround:

 <html> <body> <center> <a href="pagename.htm" target="middle">Refresh iframe</a> <p> <iframe src="pagename.htm" name="middle"> </p> </center> </body> </html> 

Both may be what you are looking for ...

+1
source

Try this in your script:

 $("#YourElement").html(htmlData); 

I do this in my rest table.

+1
source

try to empty your innerHtml every time. just:

 Element.innerHtml=""; 
0
source

Source: https://habr.com/ru/post/917131/


All Articles