繁体   English   中英

使用iframe时从上传表单上的PHP中回显jQuery脚本

[英]Echoing jQuery script from PHP on upload form while using iframe

我的文件上传具有以下HTML代码

<div id="status"></div>

<iframe name="upifrm" src="" style="display:none;"></iframe>

<form name="myForm" id="myForm" action="upload.php" method="post" enctype="multipart/form-data" target="upifrm">
<label for="fileinput" id="brsbtn" class="labtrigg">label</label> 
<input type="file" id="fileinput" name="file" />
</form>

<div id="atchs"></div>

在我的upload.php文件的结尾,我有

// . . . . . . . . . . . . .     
// $message declaration . . .

echo '<script>
parent.document.getElementById("myForm").reset(); 
parent.document.getElementById("status").innerHTML="'.$message.'";
$("#atchs", window.parent.document).after("<span>something</span>");
</script>';

前两行工作正常(它们是用纯Javascript代码编写的),但第三行却出现了错误

$("#atchs", window.parent.document).after("<span>something</span>");

“预期对象”。 我怎么解决这个问题?

即使包含了jQuery,此处也应该有一个函数名:

$("#atchs", window.parent.document).("<span>something</span>");
                                    ^^^

诸如appendprependhtmltext或您尝试执行的任何操作。 它不能只是点和括号。

试试这个,确保在您的父页面中包含了jQuery文件

top.jQuery("#atchs").html("<span>something</span>");

希望这有意义

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM