Matt Hunter
Matt Hunter

Reputation: 51

How do I mix Ruby and HTML5 in a Sinatra application?

I am getting information from the browser using Javascript / HTML5 that I want to pass back into Sinatra and Ruby.

How can I pass this information back into Sinatra so that I can use it in other parts of my code?

Upvotes: 1

Views: 252

Answers (1)

Daniel O'Hara
Daniel O'Hara

Reputation: 13438

If you want to pass any information from the client-side (JavaScript) to the server-side (Sinatra), you need to use AJAX or something like Comet. You should serialize, encode your data, send it using XMLHttpRequest and handle in the server-side code. After that, you may return an answer to your client-side.

Upvotes: 2

Related Questions