Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7419815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:08:08+00:00 2026-05-29T08:08:08+00:00

I’m following this tutorial about making an Ajax request on Rails: http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ made _form

  • 0

I’m following this tutorial about making an Ajax request on Rails:

http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/

made _form remote:
<%= form_for(@post, :remote => true) do |f| %>

My scripts are loaded:

  <script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>

Added format.js to posts_controller.rb:

  def create
    @post = Post.new(params[:post])

    respond_to do |format|
      if @post.save
        format.html { redirect_to @post, notice: 'Post was successfully created.' }
        format.js
      else
        format.html { render action: "new" }
        format.js 
      end
    end
  end

Created create.js.erb:

$('body').html("<h1><%= escape_javaScript(@post.title) %></h1>").append("<%= escape_javaScript(@post.content) %>");

But when I click the submit button nothing happens in the view but the posts are being created.
I just get this in the terminal:

Started POST “/posts” for 127.0.0.1 at 2012-02-06 12:58:02 +0800
Processing by PostsController#create as JS Parameters: {“utf8″=>”✓”,
“authenticity_token”=>”m4BT19I9aUQ+FwGD3Ub9WqKJc0IqjsPpD8+nOyQNhjo=”,
“post”=>{“name”=>”asdsad”, “title”=>”sadassad”,
“content”=>”adasdadadad”}, “commit”=>”Create Post”} (0.2ms) begin
transaction SQL (86.7ms) INSERT INTO “posts” (“content”,
“created_at”, “name”, “title”, “updated_at”) VALUES (?, ?, ?, ?, ?)
[[“content”, “adasdadadad”], [“created_at”, Mon, 06 Feb 2012 04:58:02
UTC +00:00], [“name”, “asdsad”], [“title”, “sadassad”], [“updated_at”,
Mon, 06 Feb 2012 04:58:02 UTC +00:00]] (120.0ms) commit
transaction Rendered posts/create.js.erb (307.9ms) Completed 500
Internal Server Error in 528ms

ActionView::Template::Error (undefined method `escape_javaScript’ for

<#:0xb78ecd0>):

1:    $('body').html("<h1><%= escape_javaScript(@post.title) %></h1>").append("<%= escape_javaScript(@post.content) %>");  

app/views/posts/create.js.erb:1:in
_app_views_posts_create_js_erb__76139275_96235900'
app/controllers/posts_controller.rb:45:in
create’

Rendered
/home/alex/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb
(9.9ms) Rendered
/home/alex/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb
(3.1ms) Rendered
/home/alex/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/template_error.erb
within rescues/layout (19.1ms)

Any suggestions to fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:08:09+00:00Added an answer on May 29, 2026 at 8:08 am

    There’s a typing error in that tutorial; escape_javaScript should be escape_javascript (lower case)

    See also: escape_javascript()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.