Ajax 表单提交响应
我在使用 Ajax 表单上的功能 ShowResponse 操作时遇到问题。提交表单后,我试图在 #show div 中显示一条简单的消息。 Ajax 提交工作正常,我可以收到工作警报,但无法显示 #show div。我的代码看起来像这样,
<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>
如果有人能提供帮助那就太好了。至少我只想用“成功”消息替换表单。
谢谢克里斯
I am having trouble with the function ShowResponse action on my Ajax Form. I am trying to show a simple message in the #show div once the form has been submitted. The Ajax submission is working okay and I can get an alert to work but I cant get the #show div to display. My code looks like this,
<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>
If anyone could help that would be great. As a minimum I would just like to replace the form with a 'Success' message.
Thanks
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在 $(document).ready 中包含 showResponse 函数,它会起作用吗?
Does it work if you include the showResponse function within the $(document).ready?
如果您说您可以提醒响应并可以看到它,那么我认为页面上不存在
#show
。尝试提醒$('#show').length
并看看您会得到什么。If you are saying you can alert the response and can see it then I think
#show
does not exist on the page. Try to alert$('#show').length
and see what you get.