Sunday, April 8, 2012

jQuery ajax undefined

I have a list of items I delete using AJAX.

This list is a simple list with divs and each div as an id so when the item is removed from the database I return true and then it removes the line.

Here my code:


<div id="row1">


<div><a href="...">view</a></div>

<div><a id="1">delete</a></div>



$('.delete').click(function () {

if (!confirm('Are you sure you want to delete?')) {

return false;



type: "POST",

url: '/delete_record',

data: 'id=' +,

cache: false,

success: function (result) {

if (result == 'good') {

$('#row' +;





For some reason the does not work because is undefined ... why? I have id="1" on my a href.

Source: Tips4all

1 comment:

  1. I don't see any element with a class of 'delete' in your html. Assuming it's the delete link, you need to get the id with $(this).attr('id') instead of