Reload div in jQuery

varimereweb
varimereweb used Ask the Experts™
on
Hello.  Does anyone know of a way to reload a div without using the following methods:

$(this).html("....text here....");
or
$(this).load("....page location here....");

I want to be able to reload a div without calling a page or rewriting a lot of the html within the div.  Thanks in advance!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
HainKurtSr. System Analyst

Commented:
reload... but from where? if there is no text, no page, how it should be reloaded?

Author

Commented:
I am looking for a way to reload only the contents within a <div> by its' ID.  For example, if I have a <div> in the middle of a page surrounded by other code, how would I reload only the contents in the div without reloading the whole page?
HainKurtSr. System Analyst

Commented:
check here

http://api.jquery.com/load/
<!DOCTYPE html>
<html>
<head>
  <style>body{ font-size: 11px; font-family: Arial; }</style>
  <script src="/scripts/jquery-1.4.js"></script>
</head>
<body>
  <b>Main Page Header:</b> <div id="header"></div> surrended by some Text, provided by HainKurt!...
  <script>$("#header").load("/ h1");</script>
</body>
</html>

Open in new window

Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

HainKurtSr. System Analyst

Commented:
betetr example  ;)
<!DOCTYPE html> 
<html> 
<head> 
  <script src="/scripts/jquery-1.4.js"></script> 
</head> 
<body> 
  <b>Main Page Header:</b>
  Products:
  <div id="products"></div>
  <br>surrended by some Text, provided by HainKurt!... 
  <script>$("#products").load("products.html");</script> 
</body> 
</html>

Open in new window

Author

Commented:
Thanks for the code example, HainKurt.  Is there another way to reload contents in a div without calling another file?  For example:


.... some code ....
<div id="myDiv">
   ... content in my div ...
</div>
.... more code ...
<script>$("#myDiv").reload();

Open in new window

HainKurtSr. System Analyst

Commented:
I dont get how to load again, from where?
.... some code .... 
<div id="myDiv"> 
   ... content in my div ... 
</div> 
.... more code ... 
<script>$("#myDiv").load("... some new text ...");</script>

Open in new window

Author

Commented:
From nowhere.  I'm just looking for a function that will reprocess only the contents within the div tag without making a page call or a page refresh.
HainKurtSr. System Analyst

Commented:
still do not get what are you trying to do, maybe the rigth word is not load nor reload/refresh, maybe the right word is modify...

var div = document.getElementById("myDiv").innerHTML = "<a href='http://www.hainkurt.com'>HainKurt</a>";

Author

Commented:
A solution was found for this question:

specify the div you want to load after the page and if you need any db interaction the call it within the div you are loading:

$('#dealerTable').load('index.cfm #dealerTable');
HainKurtSr. System Analyst

Commented:
question was: "to be able to reload a div without calling a page or rewriting a lot of the html within the div"
and in my previous posts I showed many times how to do this... now he wants to close this giving

$('#dealerTable').load('index.cfm #dealerTable');

as answer, which is already suggested @ 26422380, Line 11...
Sr. System Analyst
Commented:
$('#dealerTable').load('index.cfm #dealerTable');

is a call to whole page, and stripping out some part and updating the div on current page, which is similar to reloading the whole page... but just updating the div... a better approach is creating a new page, DivPage.cfm, just for this div and calling that page as:

$('#dealerTable').load('DivPage.cfm');

Author

Commented:
Either solution works.  I was only looking to refresh one portion of the page which was inside the div, not the entire page.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial