I have two tabs each tab which the default shown is "update entry" and each has an iFrame inside.
<div id="tabContainer">
<div class="tabWrapper">
<a class=active id=iEntrylist onClick="return showMenu('Entrylist','iEntrylist')" href="javascript:">Entry List</a>
<a class=nonactive id=iAddList onClick="return showMenu('AddList','iAddList')" href="javascript:">Open Deals</a>
</div>
</div>
<!-- LIST SECTION -->
<div class="tabDiv" id="Entrylist">
<iframe src="../include/EntryList.php" frameborder="0" scrolling="yes" id="_iframe2" width="100%"></iframe>
</div>
<!-- ADD LIST SECTION -->
<div class="tabDiv" id="AddList" style="display: none;">
<iframe src="../include/AddList.php" frameborder="0" scrolling="yes" id="_iframe2" width="100%"></iframe>
</div>
Now from update entry tab once the update button click the iframe1 which contain the list of entries will be reloaded. I have my codes below but it doesn't work. The update is working but reload the iFrame is not.
<script>
$(document).ready(function () {
$(".updateBTN").click(function () {
var data = $(this).attr('id');
//alert (data);
$.ajax({
type: "POST",
url: "../update.php",
data: {
'id': data
}
}).done(function (msg) {
$("#notification").html(msg);
window.setTimeout(function () {
parent.document.getElementById('iframe1').location.reload()
}, 500);
});
});
});
</script>
Try put in the end of click the return false. Some like this:
$(document).ready(function () {
$(".updateBTN").click(function () {
var data = $(this).attr('id');
//alert (data);
$.ajax({
type: "POST",
url: "../update.php",
data: {
'id': data
}
}).done(function (msg) {
$("#notification").html(msg);
window.setTimeout(function () {
parent.document.getElementById('iframe1').location.reload()
}, 500);
});
return false;
});
});
您必须使用contentWindow
来选择iFrame窗口。
parent.document.getElementById('iframe1').contentWindow.location.reload()
用这个:
$('#iframe1',window.parent.document).attr('src',$('#iframe1',window.parent.document).attr('src'));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.