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 6188073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:10:01+00:00 2026-05-24T02:10:01+00:00

I am creating a simple ajax feature into my application where a user can

  • 0

I am creating a simple ajax feature into my application where a user can increase a “like count” through a link.

I have managed to get the link to run my controller code and the browser is getting a response back, but the response is not executed.

The like link is in partial:

.likes                      
  .like_up                                                                  
    = link_to( image_tag('/images/thumb_up.png'), '/like/' + question.id.to_s, :remote => true)
  #like_count
    = 22# question.likecount                                                
  .like_down
    = link_to( image_tag('/images/thumb_down.png'), '/dislike/' + question.id.to_s, :remote => true)

And it goes into likes_controller:

def up
  @like = current_user.likes.create( :question_id => params[:question_id], :like => true )
  respond_to do |format|
    format.js
  end
end

Then in my up.js.haml I simply have a debug javascript:

alert('2');

and nothing else.

When I press the like link in browser the rails log tels me that it has rendered the js.haml

...
Rendered likes/up.js.haml within layouts/application (104.9ms)
Completed 200 OK in 923ms (Views: 116.3ms | ActiveRecord: 20.1ms)

And when I look at the response the browser gets it certainly looks like the up.js.haml rendered into my application layout where the yield tag is placed.

  <div class='content'>
    alert('2');
  </div>

I suspect that this is not what the browser wants to get back. Also when looking at the firebug console during the ajax request, nothing happens after the request is sent.

Could someone find out why this is not working? Every tutorial and guide I have found does this the same way I’m doing here.

  • 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-24T02:10:02+00:00Added an answer on May 24, 2026 at 2:10 am

    First, make sure the content-type is correct:

    curl --head -X POST http://localhost:8080/....
    

    I believe the Content-Type should be text/javascript

    Second, I think you want to disable the layout so that the DIV doesn’t appear in the output.

    def up
      @like = current_user.likes.create( :question_id => params[:question_id], :like => true )
      respond_to do |format|
        format.js { render :partial => 'up', :layout => false }
      end
    end
    

    Or maybe disable it in the whole controller with

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

Sidebar

Related Questions

I'm creating a simple ajax call to retrieve a list of user reviews. I
When creating a simple object hierarchy in Python, I'd like to be able to
Was creating a simple console application to do some prototyping and was shocked to
I'm creating a simple tag system that allows me to link a tag to
I am creating a simple application with Django. I realized that I am doing
I am creating a simple application using the MVC design pattern where my model
I'm creating my first Chrome extension, a relatively simple one with some ajax calls.
I have an Ajax request that returns search results, and I am dynamically creating
I'm using a simple ajax-enabled WCF service. I'm creating a string of XML on
I have simple AJAX function that uses jQuery to return an array of 300

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.