0
我想的iframe加载完成后加载pictures.php
一个div内id为main
...负载DIV加载完成
这里是我的index.php:
<html>
<head>
<script src='jquery.min.js' ></script>
<script src='upload.js' ></script>
</head>
<body>
<div id='main' ><?php include("pictures.php"); ?></div>
<form action='upload.php' target='tar_wp' enctype='multipart/form-data' method='POST' >
<iframe src='' name='tar_wp' width='0' height='0' onload='tar_wp()' ></iframe>
<input type='file' name='pic' id='pic' />
<button type='submit' id='submit' >submit</button>
</form>
</body>
</html>
和我的照片。 PHP:
<?php
$img = mysql_query("SELECT * FROM images");
while($rows_img = mysql_fetch_assoc($img)){
$i_img = $rows_img['image_path'];
}
echo "<img src='$i_img' width='200px' height='200px' />";
?>
和upload.php的完美的作品,它插入我所需要的图像,它只是装载不工作....
我使用iframe为目标,以避免加载整个页面,而不是只加载ID为main
股利...
,这里是我的upload.js:
$(document).ready(function(){
$("#submit").click(function{
var pic = $("#pic").val();
if(pic == ""){
$("#pic").focus();
}
else{
$.ajax({
type: 'post',
success: function() {
$("#main").load("index.php"); // load div to see changes after uploading
}
});
}
});
});
不幸的是,这不是” t加载div来查看新的上传。我必须刷新整个页面才能看到新的上传内容。我也试过这个代码的iframe上事件onload
:
function tar_wp(){
$("#main",window.parent.document).load("pictures.php");
}
任何想法是高度赞赏,在此先感谢....
顺便说一句我的主要目标是加载pictures.php在div里面ID main
的iframe加载完成后...
我觉得tar_wp是你的父文档中,但在你试图应用父dpocuments函数的功能里面... –