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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:28:57+00:00 2026-05-23T18:28:57+00:00

I need some help with my jquery which should complete a task in our

  • 0

I need some help with my jquery which should complete a task in our Rails3 application. Thanks to others on here, I have a checkbox which when clicked, is supposed to mark a task’s status as completed.

In my rails code, I have this;

<%= check_box_tag 'complete_task_1', '', false, { 'href' => completed_task_path(task.id) } %>

In my application.js, I started with this:

 $('#complete_task_1').click(function() {
  $.ajax({
    url: $(this).data('href'),
    type: 'post',
    dataType: 'html',
    success: function(data, textStatus, jqXHR) {
        $('#thing').css("color","red");
        alert ('yabadabadoo');
    }
  });
});

This gives me an error though – no route matches for /tasks

To test, I replaced the url with:

tasks/4/complete

Which toggled the status in the db but did not refresh on the page. I therefore have two questions:

  1. What’s wrong with the url / function above?
  2. What can I include so that the task disappears from page without reload?

— UPDATE —

Tried using code as per @darin-dimitrov suggestion below and I get logged out of my application… The error shown in development log is:

Started POST "/tasks" for 127.0.0.1 at 2011-07-16 13:27:32 +0100
  Processing by TasksController#create as HTML
  SQL (143.6ms)  describe `roles_users`
  User Load (0.5ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
  SQL (0.2ms)  BEGIN
  SQL (0.6ms)  COMMIT
Completed   in 454ms

Looks like it’s not getting the right url still. Should I be using POST as well?

  • 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-23T18:28:58+00:00Added an answer on May 23, 2026 at 6:28 pm

    Try this:

    { 'data-href' => completed_task_path(task.id) }
    

    and then:

    url: $(this).data('href')
    

    should give the correct url (tasks/4/complete).

    Or if you dont use the data- prefix you could use this:

    url: $(this).attr('href')
    

    but as href is not valid attribute on a checkbox the firstr solution seems better.

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

Sidebar

Related Questions

today i need help with some jquery, which I really do not have much
I'm working with jQuery for the first time and need some help. I have
I need some help adjusting the logic of my jquery function. Here's how the
I need some help. I have a div inside which there are some radio
I need some help passing arguments to a jquery function. I have an html
I have the following psudeo html. I need to write some jquery which hides
I need some jQuery ajax help. I currently have a main content div that
Hey. I need some help with jQuery Ajax calls. In javascript I have to
We need to build the javascript-based visual editor (on jQuery) which should edit some
I need some help finding a jQuery plugin which will allow me to display

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.