Php Jquery对话框错误
我正在使用对话框在我的页面上显示和提交查询表单。当我一次又一次尝试调用它时,我遇到了问题。第一次一切正常,表单提交成功。但是如果我单击“GO”按钮(在下面添加html)。我会收到此行文档的错误。 编辑:Php Jquery对话框错误,php,javascript,jquery,ajax,Php,Javascript,Jquery,Ajax,我正在使用对话框在我的页面上显示和提交查询表单。当我一次又一次尝试调用它时,我遇到了问题。第一次一切正常,表单提交成功。但是如果我单击“GO”按钮(在下面添加html)。我会收到此行文档的错误。 编辑: <div class="hidden" id="dialog"> <form action="index.php" class="testForm" id="testForm"> <div class="name" id="name">
<div class="hidden" id="dialog">
<form action="index.php" class="testForm" id="testForm">
<div class="name" id="name">
<div class="displayName" id="dispName">Name</div>
<div class="textName" id="viewName"><input type="text" class="fname" id="fullName" /></div>
<div class="hide" id="nameErr"></div>
</div>
<div class="address" id="addressDetails">
<div class="displayAddress" id="dispAddress">Address</div>
<div class="textAddress" id=""><input type="text" class="taddress" id="fullAddress" /></div>
<div class="hide" id="addressErr"></div>
</div>
<div class="submitForm" ><input type="button" class="submitDetails" id="submitInfo" name="Submit" value="Submit" onClick="validateAndSubmitForm()"/>
<a name="Close" onclick="$('#dialog').dialog('close');">Close</a>
</div>
</form>
</div>
{
}
表单提交的回调函数
$.ajax({
type:'POST',
url:"processForm.php",
data:"name="+name+"&address="+address,
dataType:"html",
success:function(msg){
if(msg=="success"){
$("#dialog", window.parent.document).html("<div class='pad5'><div class='flt' style='padding-left:3px; width:235px;'><div class='thanx_msg'>Thank you for submitting the details. <br /><div class='spacer5'> </div><span class='gre'>Our Sales team shall revert to your query soon.</span></div></div><div class='spacer5'> </div><div style='padding-left:3px;' class='text'><strong>You can also:</strong></div><div style='margin-left:20px; line-height:20px;'>• Apply for a <a href='homeloan.php'>Home Loan</a><br />• Visit <a href='http://www.proptiger.com'>proptiger.com</a> for more properties<br />• See our <a href='http://www.proptiger.com/blog'>Blog</a> for latest updates</div></div><br/><div class='msg' style='color:red;'>Click to close the box</div>");
$(function(){
$('#dialog').click(function() {
closeDialog();
});
});
}
else
{
alert("Operation cannot be completed,please try again");
}
}
$.ajax({
类型:'POST',
url:“processForm.php”,
数据:“name=“+name+”&address=“+address,
数据类型:“html”,
成功:功能(msg){
如果(消息==“成功”){
$(“#dialog”,window.parent.document).html(“感谢您提交详细信息。
我们的销售团队将很快回复您的查询。您也可以:&bull;申请访问
&bull;了解更多属性
&bull;查看我们的最新更新
单击关闭该框”);
$(函数(){
$(“#对话框”)。单击(函数(){
closeDialog();
});
});
}
其他的
{
警报(“操作无法完成,请重试”);
}
}
但我也面临同样的问题。.reset()
行出错。
谢谢您抽出时间。更新答案 如果希望有一个可重用的对话框,请按如下方式操作:
)。使用CSS类使其不会立即可见,例如:
HTML:
<div id="dialog" class="hidden">...</div>
CSS:
.hidden { display: none }
HTML:
...
CSS:
.hidden{显示:无}
$(“#dialog”).dialog(选项)
。请确保在选项中设置autoOpen:false
$(“#dialog”).dialog(“打开”)
$(“#dialog”).dialog(“close”)
.dialog( "close" )
关闭对话框。感谢您的及时回复,但我已经尝试过了,但它不起作用!!!:(我检查了
document.getElementById(“enqFormProp”)的手表)
最初它会显示所有表单属性,但在第一次提交后就不会了。也找不到调试的方法!!@forummember:我不知道为什么会发生这种情况,因为代码有点复杂,当然这是有原因的:)查看更新后的答案以了解演练方法,并以这种方式进行。因此在我的例子中,函数showsubrequform(title,perpose,pagename)
将进入无条件调用部分,我将使用$(“#dialog”).dialog(“打开”)
$(“#dialog”).dialog(“关闭”)
用于调用对话框。@forummember:是的,尽管我一点也不知道您除了调用.dialog()之外为什么还要做其他事情
在那里。这是表单验证部分,这些是我设置为空白的错误div,以清除任何错误消息。在我的表单中添加了一部分,其中包含前2-3个div。是的,我尝试关闭,但仍然得到相同的错误。因此,这意味着可能是其他原因导致问题。我以不同的方式实现了它。可能是w我所做的是在html中添加了另一个
,并用于在回调时显示成功消息。因此,带有表单的div保持不变,并且没有像以前那样在内容中更改。请告诉我这是否是正确的方法。
$.ajax({
type:'POST',
url:"processForm.php",
data:"name="+name+"&address="+address,
dataType:"html",
success:function(msg){
if(msg=="success"){
$("#dialog", window.parent.document).html("<div class='pad5'><div class='flt' style='padding-left:3px; width:235px;'><div class='thanx_msg'>Thank you for submitting the details. <br /><div class='spacer5'> </div><span class='gre'>Our Sales team shall revert to your query soon.</span></div></div><div class='spacer5'> </div><div style='padding-left:3px;' class='text'><strong>You can also:</strong></div><div style='margin-left:20px; line-height:20px;'>• Apply for a <a href='homeloan.php'>Home Loan</a><br />• Visit <a href='http://www.proptiger.com'>proptiger.com</a> for more properties<br />• See our <a href='http://www.proptiger.com/blog'>Blog</a> for latest updates</div></div><br/><div class='msg' style='color:red;'>Click to close the box</div>");
$(function(){
$('#dialog').click(function() {
closeDialog();
});
});
}
else
{
alert("Operation cannot be completed,please try again");
}
}
HTML:
<div id="dialog" class="hidden">...</div>
CSS:
.hidden { display: none }
.dialog( "destroy" )
.dialog( "close" )