【发布时间】:2009-10-05 22:45:59
【问题描述】:
我正在尝试在 Rails 2.3.4 中构建联系表单。我正在使用 jQuery Form 插件和这个 (http://bassistance.de/jquery-plugins/jquery-plugin-validation/) 进行验证。一切都在我的开发环境(mac os x snow leopard)中运行,加载 gif 出现,并且在我的日志中发送电子邮件并显示“请求完成”通知。但是在我的生产机器上,加载 gif 只是继续进行,并且没有发送表单。我已经等了很久了,什么都没有。
这是我的代码:
/public/javascripts/application.js
// client-side validation and ajax submit contact form
$('#contactForm').validate( {
rules: {
'email[name]': { required: true },
'email[address]': {
required: true,
email: true
},
'email[subject]': {
required: true
},
'email[body]': {
required: true
}
},
messages: {
'email[name]': "Please enter your name.",
'email[address]': "Please enter a valid email address.",
'email[subject]': "Please enter a subject.",
'email[body]': "Please enter a message."
},
submitHandler: function(form) {
$(form).ajaxSubmit({
dataType: 'script',
beforeSend: function() {
$(".loadMsg").show();
}
});
return false;
}
});
我正在使用 submitHandler 发送实际的 ajaxSubmit。我为加载图形添加了“dataType:”脚本”和“beforeSubmit”。
def send_mail
if request.post?
respond_to do |wants|
ContactMailer.deliver_contact_request(params[:email])
flash[:notice] = "Email was successfully sent."
wants.js
end
end
end
在开发中一切正常,但在生产中却不行。我错过了什么或做错了什么?
【问题讨论】:
标签: jquery ruby-on-rails ajax forms plugins