I have a page which opens another page using window.open and does some work and refreshes whole parent page . Is it possible to refresh content of a div/table on parent page using JQuery/Javascript ?
FYI : Here the content of the div is not changing there is an image inside div which is edited by child window which I want to update but that image does not have unique id so I want to refresh whole div .
Thanks.
I have a page which opens another page using window.open and does some work and refreshes whole parent page . Is it possible to refresh content of a div/table on parent page using JQuery/Javascript ?
FYI : Here the content of the div is not changing there is an image inside div which is edited by child window which I want to update but that image does not have unique id so I want to refresh whole div .
Thanks.
Share Improve this question asked Apr 4, 2011 at 17:05 Pit DiggerPit Digger 9,80023 gold badges81 silver badges125 bronze badges3 Answers
Reset to default 4Pure JavaScript (not JQuery) solution : wrap your div in an iframe, give it an id myFrame
, then refresh it from the child like this:
parent.document.getElementById("myFrame").reload();
You can use the .load()
method of jQuery to quickly update the contents of a container
http://api.jquery./load
Simple as
$('#result').load('ajax/test.html', function() {
alert('Load was performed.');
});
$("#myDiv", window.parent.document).load("page.html", function(){
alert("Portion of page loaded");
});
The second parameter of $() is the context to search into. Default to document.
You can use .html() instead of .load() if you want reload from html string instead of using another page.