finished CSRF/AJAX, closes issue #21

This commit is contained in:
Ken Johnson
2013-06-06 22:40:52 -04:00
parent cc38bd3f2a
commit 39d2e9d79f
2 changed files with 35 additions and 2 deletions
+18
View File
@@ -36,6 +36,24 @@ class TutorialsController < ApplicationController
def csrf
@meta_code_bad = %{<%#= csrf_meta_tags %> <!-- <~ What is this for? I hear it helps w/ JS and Sea-surfing.....whatevz -->}
@meta_code_good = %{<%= csrf_meta_tags %> }
@ajax_code_good = %q{
("#example_submit_button_id").click(function(event) {
var valuesToSubmit = $("#example_form_id").serialize();
event.preventDefault();
$.ajax(\{
url: "/example",
data: valuesToSubmit,
type: "POST",
success: function(response) \{
alert('success!');
},
error: function(event) \{
alert('failure!');
\}
\});
\});
\} }
end
def misconfig