I am trying to use jQuery to submit a form to my Sinatra app, but when POSTing via the AJAX, the Sinatra app is displaying a blank page. I would like it to stay on the same page, and update the content I have specified in the javascript. Here is my code, stripped down:
post '/register' do
register( params )
end
get '/register' do
haml :register
end
And here is my javascript in the haml file:
:javascript
$(function() {
$("button#submit").click(function(){
$.ajax({
type: "POST",
url: "/register",
data: $('form.register').serialize(),
success: function(){
$("#message").html("Successfully registered")
},
error: function(){
$("#message").html("Not Successful")
}
});
});
});