如何使用php在thickbox中抛出服务器端错误消息
我的问题简介:
我正在使用 php 在服务器端验证注册表单,并且工作正常。
现在我的问题是我需要使用像弹出窗口一样的厚框来显示错误消息。
这可能吗。如果是,请解释一下如何?
提前致谢
代码:
<script type="text/javascript" src="thickbox/jquery-latest.js"></script>
<script type="text/javascript" src="thickbox/thickbox.js"></script>
<link href="thickbox/thickbox.css" rel="stylesheet" type="text/css" />
<span class="prtexterror" style="color:#FF0000;display:none;" id="hiddenModalContent" >{$error_login}</span>
{literal}
<script language="javascript" type="text/javascript">
$(document).ready(function() {
tb_show("Please, login", "?tb_inline=true&inlineId=hiddenModalContent&height=180&width=300&modal=true", null);
});
</script>
{/literal}
My prob in brief:
I am validating a registration form with server side using php and its working fine.
Now my prob is i need to show the error message using thickbox like popup.
Is that possible. If yes please explain how?
thanks in advance
Code:
<script type="text/javascript" src="thickbox/jquery-latest.js"></script>
<script type="text/javascript" src="thickbox/thickbox.js"></script>
<link href="thickbox/thickbox.css" rel="stylesheet" type="text/css" />
<span class="prtexterror" style="color:#FF0000;display:none;" id="hiddenModalContent" >{$error_login}</span>
{literal}
<script language="javascript" type="text/javascript">
$(document).ready(function() {
tb_show("Please, login", "?tb_inline=true&inlineId=hiddenModalContent&height=180&width=300&modal=true", null);
});
</script>
{/literal}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我浏览了Thinkbox的文档。看来您必须将错误消息放在带有 id 的 div 上:
然后您的脚本应该提供要在 inlineId 参数中显示的 div 的 id:
I glanced at Thinkbox's documentation. It seems that you must put your error message on a div with an id:
Your script should then provide the id of the div to be shown in the inlineId parameter:
好的,我快速浏览了 Thickbox 文档和示例,特别是我相信您正在使用一个框架来创建此功能。
文档中没有很好地解释,但是 href 中引用的“hiddenModalContent”实际上是指一个 DIV 元素,其中包含要在 Thickbox 中显示的文本哪个弹出窗口。因此,如果您没有 ID 为“hiddenModalContent”的元素,这可以解释为什么您会收到一个空的弹出窗口。
解决方案是什么? Replace:
With:
然后,当
$(document).ready(...
执行时,该 DIV 的内容将用作 Thickbox 的内容。OK, I have had a quick look at the Thickbox Documentation and Examples, specifically the one I believe you are using as a framework to create this functionality.
It is not terribly well explained in the documentation, but the "hiddenModalContent" referred to in the href actually refers to a DIV element which contains the text to be displayed in the Thickbox which popsup. So if you have no element with an ID of "hiddenModalContent" that would explain why you are getting an empty popup.
The solution? Replace:
With:
Then, when the
$(document).ready(...
executes, the content of that DIV will be used as the content of the Thickbox.