Hello all, I’m hoping someone could help me I’m really getting nowhere
with this.
I have a form that submits info to a mysql database and it seems to
work. The data is submitted but my problem is with the ajax. Once
submitted I’d like the form to disappear and a “success” message to show
up but I’m having problems. Here is the code from my Sinatra app.
class Contact
include DataMapper::Resource
property :id, Serial
property :full_name, String
property :email, Text
property :subject, Text
property :body, Text
property :date, DateTime
database.table_exists?(Contact) or database.save(Contact)
end
And the form response is here:
post ‘/’ do
contact=Contact.create(:full_name => params[:fullname], :email =>
params[:email], :subject => params[:subject], :body => params[:message],
:date => Time.now)
redirect (’#/’)
end
Here is the web form:
And I have the following javascript validating the form - which works -
but on submit I’d like the form to disappear and a “success” message to
appear:
I’ve tried adding in other code but to no avail. If someone could start
me off int he right direction I’d appreciate it, I’m just not having any
luck. Really…thanks in advance.