简体   繁体   English

如何使用PHP在thickbox中抛出服务器端错误消息

[英]How to throw a server side error message in thickbox using php

My prob in brief: 我的问题简述:

I am validating a registration form with server side using php and its working fine. 我正在使用php及其服务器正常验证服务器端的注册表格。

Now my prob is i need to show the error message using thickbox like popup. 现在我的问题是我需要使用诸如弹出框的thickbox显示错误消息。

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}

I glanced at Thinkbox's documentation. 我看了一下Thinkbox的文档。 It seems that you must put your error message on a div with an id: 看来您必须将错误消息放在ID为的div上:

<div id="errorMessage">
{$errorMessage}
</div>

Your script should then provide the id of the div to be shown in the inlineId parameter: 然后,您的脚本应提供要在inlineId参数中显示的div的ID:

tb_show("HAI","#TB_inline? height=240&amp;width=405&amp;inlineId=errorMessage&amp;modal=true",null);

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. 好的,我快速浏览了Thinbox文档和示例 ,尤其是我认为您将其用作创建此功能的框架的示例

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. 它在文档中没有很好地解释,但是href中引用的“ hiddenModalContent ”实际上是指一个DIV元素,其中包含要在弹出的Thinbox中显示的文本。 So if you have no element with an ID of " hiddenModalContent " that would explain why you are getting an empty popup. 因此,如果您没有ID为“ hiddenModalContent ”的元素,这将解释为什么您会得到一个空的弹出窗口。

The solution? 解决方案? Replace: 更换:

<a href="#TB_inline?height=240&amp;width=405&amp;inlineId=hiddenModalContent&amp;modal=true" class="thickbox">{$errorMessage}</a>

With: 带有:

<div id="hiddenModalContent" style="display:none;">{$errorMessage}</div>

Then, when the $(document).ready(... executes, the content of that DIV will be used as the content of the Thickbox. 然后,当执行$(document).ready(... ,该DIV的内容将用作Thinbox的内容。

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

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