我在我的Ajax表单上遇到ShowResponse函数的问题。我试图在表单提交后在#show div中显示一条简单的消息。阿贾克斯提交工作正常,我可以得到一个警报工作,但我不能让#show div显示。我的代码看起来像这样,Ajax表单提交响应
<script type="text/javascript" src="/uploads/JS/jquery.form.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var options = {
target: '#contact_form_94',
success: showResponse
};
$('#m477famoduleform_2').ajaxForm(options);
});
function showResponse(responseText, statusText, xhr, $form) {
alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
'\n\nThe output div should have already been updated with the responseText.');
}
</script>
如果有人能帮上忙,那会很棒。至少我只想用'成功'消息来替换表单。
感谢
克里斯
你可以使用萤火虫或类似的东西来看看你的#show div是否正在接收你的“responseDoc”?如果是这样,是不是你的div不可见,你需要设置它的CSS显示属性? –
确保存在“#contact_form_94”元素,可能会执行类似$('#contact_form_94')的操作。 –