<%= form_tag "/blog_admin", :method => :post do %>

Title:

Content:

<% end %>
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" %> <%= javascript_tag do %> $(function() { $(".preview-content").click(function() { var $this = $(this).attr("disabled", "disabled"); $.ajax({ url: "/blog_admin/preview_content", type: "post", data: { authenticity_token: $("form input[name='authenticity_token']").val(), content: $("textarea[name='content']").val() }, dataType: "text", success: function(text) { $(".preview-content").html(text); $this.removeAttr("disabled"); }, error: function() { $(".preview-content").html('
There was an error.
'); $this.removeAttr("disabled"); } }); return false; }); }); <% end %>