jQuery Checkbox Error

Posted by Zack Fernandes on Stack Overflow See other posts from Stack Overflow or by Zack Fernandes
Published on 2010-05-16T21:25:08Z Indexed on 2010/05/16 21:30 UTC
Read the original article Hit count: 276

Filed under:

Hello, I am working on a jQuery-based todo list interface, and have hit a bit of a wall. The jQuery I am working with is a bit hacked together from various tutorials I have read, as I'm a bit of a beginner.

$('#todo input:checkbox').click(function(){
  var id = this.attr("value");
  if(!$(this).is(":checked")) {
    alert("Starting.");
    $.ajax({
      type: "GET",
      url: "/todos/check/"+id,
      success: function(){
        alert("It worked.")
      }
    });
  }
})

This is the HTML I am using,

<div id="todo"> 
  <input type="checkbox" checked="yes" value="1"> Hello, world. <br />
</div>

Any help on this would be greatly appreciated. For reference, thereason I have alerts in the jQuery is for debugging. The reason I can tell the code isn't working is because I am not getting these alerts. Thanks.

© Stack Overflow or respective owner

Related posts about jQuery