Question: I'm making a core data model, and I have a Client entity that has a to-many relationship to an Appointment entity. An Appointment can turn into a Transaction (if it has been paid for etc.), and I need to keep track of the Appointments of Clients that have turned into Transactions (where Transaction is an entity along with other attributes). A Client can have multiple Transactions, and a Transaction can have multiple Clients (optional). If I put a relationship between Transaction and Client, then I don't think there's a way I can detect which of the appointments have turned into transactions and which haven't...
Any help as to how I can set my model up to do this would be appreciated.
Thanks

Answer: 
It sounds like the ajax call is made when one of the elements is clicked, but you need to pass different values in the ajax call depending on which element is clicked. Rather than use an "onclick" attribute, you could do the following:

HTML:

```
<div class="test" data-param1="value1a" data-param2="value2a">hi</div>
<div class="test" data-param1="value1b" data-param2="value2b">hey</div>
<div class="test" data-param1="value1c" data-param2="value2c">yo</div>
<div class="test" data-param1="value1d" data-param2="value2d">What's up</div>

```

JavaScript:

```
$('.test').click(function() {
    var $div = $(this);
    $.ajax(url, {
        data: {
            param1: $div.attr('data-param1'),
            param2: $div.attr('data-param2')
        },
        success: function() {
            $div.toggleClass("btn-danger btn-success");
        }
    });
});

```

Of course, you would set the values of the `data-` attributes using PHP variables.
Is it not possible to give each of these an ID so you can access them directly?

If you are triggering them on a callback function can you create a reference to the clicked div in a variable?

i.e. 

```
 var clicked;

 $('.test').click(function(){
     clicked = $(this);
 });

```

then in your ajax response:

```
 clicked.toggleClass("btn-danger btn-success");

```